Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Browser Display

(Page 2 of 2)
> >
Quote Reply
Re: [Alex] Browser Display In reply to
Thanks for the code Alex!

I've got this now, which appears to work (minus the actual hyperlinking).

I am going to look at your version also as a solution to this.

Cool



Code:


sub {
#return the Full_Name for a category based on the category_id available in browser_category.html

my $rec = shift;
my $category_id = $rec->{category_id};
my $cat = $DB->table('Category')->select( ['Full_Name'], { ID => $category_id } )->fetchrow_array;

$cat =~ s,(.*?)/.+/(.*?/.+)$,$1/.../$2,;

return $cat;
}
Quote Reply
Re: [Alex] Browser Display In reply to
Hi Alex,



This global:

sub {
my $tags = shift;
my ($full_name) = $DB->table('Category')->select('Full_Name',
{ ID => $tags->{category_id} })->fetchrow; require Links::Build;
my $title = Links::Build::build('title_linked', $full_name);
return $title; }



could you tell me what to do so that it does not display the name of the current category a user is viewing?

In other words all cats except the last one.



Thank you. Smile
Quote Reply
Re: [nt6] Browser Display In reply to
Try changing:

my $title = Links::Build::build('title_linked', $full_name);

to

my $title = Links::Build::build('title_linked', substr($full_name, 0, rindex($full_name, '/')) );
Quote Reply
Re: [Paul] Browser Display In reply to
Thanks Paul it worked.

The only thing "not nice" is that the last category was not linked before your modification. Now since the last category has been "chopped off", the new (second to) last is not linked. So a visitor can not click up one level anymore ... Is there something to add or remove so that everything returned by that global is linked back to it's category?
Quote Reply
Re: [nt6] Browser Display In reply to
You would need to duplicate title_linked and rename it it as it automatically stops hyperlinking at the final category of the trail.

Last edited by:

Paul: Aug 29, 2002, 7:29 AM
Quote Reply
Re: [Paul] Browser Display In reply to
I think I can handle that if you do not mind telling me what to do.

So I copy and paste the title linked sub, but then what needs to be renamed?

I tried this:

$SUBS{build_title_category_linked} = <<'END_OF_SUB';


sub build_title_category_linked {
# ------------------------------------------------------------------


# Generate a linked category 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);

$db = $DB->table('Category');


@dirs = split (/\//, $input);
$last = pop @dirs unless ($complete);

for (0 .. $#dirs) {
$path = "/" . $db->as_url ( join "/", @dirs[0 .. $_] );
$output .= qq| <a class"menu_links" href="$CFG->{build_root_url}$path/$CFG->{build_index}"><img src="http://www.righters.com/_base/images/default/" border=0 width="10" height="10" vspace="0" hspace="0"><small style="text-decoration:none;">$dirs[$_]</a>&nbsp;</small> ><br> |;
}
if ($complete) {
chop $output; chop $output;
}
else {
$output .= " $last";
}
return $output;
}
END_OF_SUB

$SUBS{build_title_category_linked} = <<'END_OF_SUB';



but got an error. Where did I mess up?
Quote Reply
Re: [nt6] Browser Display In reply to
I think thats the wrong routine, you are using build_title_linked.

It looks like you can pass in a hashref to get it to do what you want, using { complete => 1 }.....as well as name => the_category
Quote Reply
Re: [Paul] Browser Display In reply to
That was in build.pm.

I am not sure about there being a difference between build_title_linked & title_linked... Crazy
Quote Reply
Re: [nt6] Browser Display In reply to
title_linked is what you call, build_title_linked is the actual subroutine name. Build.pm uses compile on demand so build_ is prepended on to the string you pass in (title_linked)

Last edited by:

Paul: Aug 29, 2002, 7:51 AM
Quote Reply
Re: [Paul] Browser Display In reply to
Okay Paul Thank you for your time. I am still stuck. Crazy
Quote Reply
Re: [nt6] Browser Display In reply to
Code:
my $title = Links::Build::build('title_linked', { complete => 1, name => substr($full_name, 0, rindex($full_name, '/')) } );

Last edited by:

Paul: Aug 29, 2002, 8:18 AM
Quote Reply
Re: [Paul] Browser Display In reply to
Sorry for being ingnorant but is this a new global or a hack? if it's a hack what should I do with it?
Quote Reply
Re: [nt6] Browser Display In reply to
It goes in the global to replace the line you originally had.
Quote Reply
Re: [Paul] Browser Display In reply to
Great. Nice one Paul. Thank you.



The purpose for me is to show the path of categories the visitor has followed to get to the current category. That current category's style is now independent of the other categories...

Cool
> >