Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Categories from a link in the detailed page

Quote Reply
Categories from a link in the detailed page
Hi,

I´m using the following global to include the categories from a link in the detailed page

-----------------------------
sub {
my $tags = shift;
my $seen;
my $id = $tags->{'ID'};
my $db = $DB->table ('Category','CatLinks');
my $sth = $db->select ( { LinkID => $id }, ['Name','Full_Name'] );
my $cat;
while (my ($name,$full_name) = $sth->fetchrow_array) {
if ($seen->{$name}) { next; }
$full_name =~ s/ /_/g;
$cat .= qq~<a href="$CFG->{build_root_url}/$full_name/index.html">$name</a><br>~;
$seen->{$name} = 1;
}
return $cat;
}
-------------------------------

I would need some categories not to appear. For example the categories with these Id:

ID=234
ID=3
ID=112

Could someone indicate what I should do on the global?

Thanks in advance.

JoseML
Quote Reply
Re: [JoseML] Categories from a link in the detailed page In reply to
Hi,

This should do it:

Code:
sub {

my $tags = shift;
my $seen;
my $id = $tags->{'ID'};

my $db = $DB->table ('Category','CatLinks');
my $sth = $db->select ( { LinkID => $id }, ['ID','Name','Full_Name'] );
my $cat;
while (my ($id,$name,$full_name) = $sth->fetchrow_array) {

if ($id =~ /^234|3|112$/) { next; }
if ($seen->{$name}) { next; }
$full_name =~ s/ /_/g;
$cat .= qq~<a href="$CFG->{build_root_url}/$full_name/index.html">$name</a><br>~;
$seen->{$name} = 1;
}

return $cat;

}

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Categories from a link in the detailed page In reply to
Andy, the global works fine. Thanks for your help.

JoseML
Quote Reply
Re: [JoseML] Categories from a link in the detailed page In reply to
Hi, I`ve been using:
--------------
sub {
my $tags = shift;
my $seen;
my $id = $tags->{'ID'};
my $db = $DB->table ('Category','CatLinks');
my $sth = $db->select ( { LinkID => $id }, ['ID','Name','Full_Name'] );
my $cat;
while (my ($id,$name,$full_name) = $sth->fetchrow_array) {
if ($id =~ /^234|3|112$/) { next; }
if ($seen->{$name}) { next; }
$full_name =~ s/ /_/g;
$cat .= qq~<a href="$CFG->{build_root_url}/$full_name/index.html">$name</a><br>~;
$seen->{$name} = 1;
}

return $cat;
}
------------------
but I need for the whole name of the category to be read so I changed it this way:

$cat .= qq~<a href="$CFG->{build_root_url}/$full_name/index.html">$full_name</a><br>~;

However the name (Category/subcategory1/subcategory2 ... etc) is too long.

I need someone to tell me how I can break line.

Thanks in advance.

JoseML
Quote Reply
Re: [JoseML] Categories from a link in the detailed page In reply to
Hi,

I would suggest more like changing "/" with " / " in the Full_Name, that way - once it overlaps, it will just go onto a newline on its own :)

Code:
sub {
my $tags = shift;
my $seen;
my $id = $tags->{'ID'};
my $db = $DB->table ('Category','CatLinks');
my $sth = $db->select ( { LinkID => $id }, ['ID','Name','Full_Name'] );
my $cat;
while (my ($id,$name,$full_name) = $sth->fetchrow_array) {

if ($id =~ /^234|3|112$/) { next; }
if ($seen->{$name}) { next; }

$full_name =~ s/ /_/g;

my $full_name2 = $full_name;
$full_name2 =~ s|/| / |g;
$cat .= qq~<a href="$CFG->{build_root_url}/$full_name/index.html">$full_name2</a><br>~;
$seen->{$name} = 1;
}

return $cat;
}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Aug 22, 2008, 3:10 AM
Quote Reply
Re: [Andy] Categories from a link in the detailed page In reply to
Thanks Andy for your help but I have tried the modification and it doesn´t work.


href="$CFG->{build_root_url}/$full_name/index.html" ----> It's OK

>$full_name2< ----> Nothing happens


Thanks again,

JoseML

Last edited by:

JoseML: Aug 21, 2008, 5:10 PM
Quote Reply
Re: [JoseML] Categories from a link in the detailed page In reply to
Hi,

Did you change the WHOLE global (not just the one line) ?

Should work fine.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Categories from a link in the detailed page In reply to
Hi Andy,

yes, I have changed the whole global.

Cheers,

JoseML
Quote Reply
Re: [JoseML] Categories from a link in the detailed page In reply to
Oops, I see the problem - please try now =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Categories from a link in the detailed page In reply to
Sorry Andy, but I don't understand. I have tried with the whole global and it doesn't work.

Cheers,

JoseML
Quote Reply
Re: [JoseML] Categories from a link in the detailed page In reply to
Hi,

So you tried this:

Code:
sub {
my $tags = shift;
my $seen;
my $id = $tags->{'ID'};
my $db = $DB->table ('Category','CatLinks');
my $sth = $db->select ( { LinkID => $id }, ['ID','Name','Full_Name'] );
my $cat;
while (my ($id,$name,$full_name) = $sth->fetchrow_array) {

if ($id =~ /^234|3|112$/) { next; }
if ($seen->{$name}) { next; }

$full_name =~ s/ /_/g;

my $full_name2 = $full_name;
$full_name2 =~ s|/| / |g;

$cat .= qq~<a href="$CFG->{build_root_url}/$full_name/index.html">$full_name2</a><br>~;
$seen->{$name} = 1;
}

return $cat;
}

I havn't tested it, but I can't see any reason why that wouldn't work ;)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Categories from a link in the detailed page In reply to
Thanks Andy, that is working now.

Cheers,

JoseML