Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Changing the ':' in the bread crumb?

Quote Reply
Changing the ':' in the bread crumb?
Anyone have a clue where I can find the code that regulates the bread crumb tag so I can change the seperator ":" to something else?

Code:
<%title_linked%>
Quote Reply
Re: [misteraven] Changing the ':' in the bread crumb? In reply to
This is hard coded into Links. However, this has been discussed before and you can write a global to rewrite it

http://www.gossamer-threads.com/...i?post=218409#218409

http://www.gossamer-threads.com/...i?post=193258#193258
Quote Reply
Re: [afinlr] Changing the ':' in the bread crumb? In reply to
I tried editing the Build.pm file as specified in the link you supplied:


sub build_title_linked {
# ------------------------------------------------------------------
# Generate a linked title.
#
my $input = shift;
my $complete = 0;
my $home = 1;
if (ref $input) {
$complete = $input->{complete} || 0;
$home = defined $input->{home} ? $input->{home} : 1;
$input = $input->{name};
}
my (@dirs, $dir, $output, $path, $last, $db, $top);

$db = $DB->table('Category');
$top = Links::language('LINKS_TOP') || 'Top';

@dirs = split (/\//, $input);
$last = pop @dirs unless ($complete);
$output = $home ? qq| <a href="$CFG->{build_root_url}/$CFG->{build_index}">$top</a> :| : '';
for (0 .. $#dirs) {
$path = "/" . $db->as_url ( join "/", @dirs[0 .. $_] );
$output .= qq| <a href="$CFG->{build_root_url}$path/$CFG->{build_index}">$dirs[$_]</a> :|;

But now it hangs when I build my pages in admin. I tried escaping quotes, no quotes, and simply deleting the colons, and it still seems to break things. Can someone please be specific at how this can be done? I'd like to add " > " instead of " : ".

Thanks.

Last edited by:

misteraven: Apr 16, 2003, 8:45 AM
Quote Reply
Re: [misteraven] Changing the ':' in the bread crumb? In reply to
Sorry, I should have taken a bit more time and given you the global - editing the core code is not a good idea.

sub {
my $tags = shift;
my $title_linked = $tags->{title_linked};
$title_linked =~ s/:/>/g;
return $title_linked;
}

Put this in your list of Template Globals and call it something like tl_replace

Then you can call it in your tempate using <%tl_replace%> instead of <%title_linked%>
Quote Reply
Re: [afinlr] Changing the ':' in the bread crumb? In reply to
afinir,

Many thanks for all your help. I did exactly what you said and it works great. My only question now is how do I put a space before the " > " since it displays as:

"Home> Category" rather than "Home > Category"

Sorry I'm not much of a perl/cgi coder. Thanks again for the help.

Last edited by:

misteraven: Apr 17, 2003, 8:45 AM
Quote Reply
Re: [misteraven] Changing the ':' in the bread crumb? In reply to
$title_linked =~ s/:/>/g;

This is the line that does the replacement. s/oldpattern/newpattern/ replaces the oldpattern with the newpattern and the g means do it globally - i.e. not just for the first occurrence. I don't think that this line should be changing any spacing - is it possible that you removed the space in your build.pm file while you were editing it? Anyway, you should be able to fix it by adding the space back in:

$title_linked =~ s/:/ >/g;

Laura.
Quote Reply
Re: [afinlr] Changing the ':' in the bread crumb? In reply to
Kinda strange. I checked one of the template pages where I didnt change the global and it displays:

Home : Category

However, on the pages with the new global it displays:

Home> Category

I double checked Build.pm and I believe it's been reset to how it was since I compared it with my post where I showed the code.

Any other ideas?

Also adding the space "$title_linked =~ s/:/ >/g;

" didnt do anything. Can you insert markup like &nbsp; instead?
Quote Reply
Re: [misteraven] Changing the ':' in the bread crumb? In reply to
Actually, I also just noticed that the replaced title has the link totally wrong as well.
Quote Reply
Re: [misteraven] Changing the ':' in the bread crumb? In reply to
Hmm, very strange. Yes, try it with &nbsp;

Does it just happen after Home or after both Home and Category when you have a subcategory?
Quote Reply
Re: [misteraven] Changing the ':' in the bread crumb? In reply to
Totally wrong in what way?
Quote Reply
Re: [afinlr] Changing the ':' in the bread crumb? In reply to
It's giving me this as a link:

http://www.domain.com/links/New/http%3E//www.domain.com/links/index.html

Rather than:

http://www.domain.com/links/index.html
Quote Reply
Re: [misteraven] Changing the ':' in the bread crumb? In reply to
Oh yes, of course - I couldn't see why there would be a colon in the link - sorry!

Try using

$title_linked =~ s/\s:\s/\s>\s/g;

so it only matches space : space in the original and wont mess up your links.
Quote Reply
Re: [afinlr] Changing the ':' in the bread crumb? In reply to
You'll need:

$title_linked =~ s/\s:\s/ > /g;

\s will only work in the pattern match. If you include it in the replacement it will actually print out \s

You could just do this though:

$title_linked =~ s/ : / > /g;

Last edited by:

Paul: Apr 17, 2003, 10:41 AM
Quote Reply
Re: [Paul] Changing the ':' in the bread crumb? In reply to
Thanks Paul. Strange what rubbish you can type when you're not really concentrating!
Quote Reply
Re: [afinlr] Changing the ':' in the bread crumb? In reply to
I'm guilty of that more often than you =)
Quote Reply
Re: [Paul] Changing the ':' in the bread crumb? In reply to
Ok, the last two suggestions from Paul did fix the links, however, it didn't fix the space issue. I'm still getting results like:

Home> Category

Thanks for the help. Any idea how to fix the space issue?

Last edited by:

misteraven: Apr 17, 2003, 11:05 AM
Quote Reply
Re: [misteraven] Changing the ':' in the bread crumb? In reply to
It shouldn't be doing that. Is Build.pm definitely back to its original state?
Quote Reply
Re: [Paul] Changing the ':' in the bread crumb? In reply to
I just copied and pasted the code from my post above, so I'm pretty positive Build.pm is back to it's original state. Also, like I said before, any changes to it at all made it stop working.

Any other ideas?
Quote Reply
Re: [misteraven] Changing the ':' in the bread crumb? In reply to
Try this:

$title_linked =~ s/ : /&nbsp;> /g;

I think that this must be something to do with the template parser. I assume that in the compressed version of the page it takes out what it thinks are unnecessary spaces which include spaces within tags.
Quote Reply
Re: [afinlr] Changing the ':' in the bread crumb? In reply to
Bingo!

That did it! Again, many many thanks for the great help and persistence. I appreciate it.