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

Custom Global - Listing Only Certain Categories on Detailed Page

Quote Reply
Custom Global - Listing Only Certain Categories on Detailed Page
Hello all,

Awhile back I asked for some help getting a custom global that would allow me to list all the link's categories on the detailed page. After a few tries, and with some help from others, I got it to work.

Now I would like to do the same thing, but narrow the number and depth of the categories that are listed. The custom global that was created for the above example almost works, it just needs to be tweaked somewhat. I need a global that will only output categories for a certain level in the directory. For example, the link, Where to Work in Canada? is placed in a number of different topical categories - two to be exact: Labour and Markets and Children and Family. Now, I would like the global (that will be placed on the detailed page of the link) to list all the links categories from the "Policy Publications" level of the directory. Each topical category has three sub categories, "Policy Organizations", "Policy Publications" and "Policy Researchers".

So on the detailed page for the link
Where to Work in Canada? I'd like the "Policy Subjects / Category:" (look down the page to the "Policy Paper Details") section to say that following:

Labour and Markets
Children and Family

and have those links link back to publication section of their topical categories. (as you see in the example above).


Is this doable?

Cheers

Greg

Quote Reply
Re: [mapleleafweb] Custom Global - Listing Only Certain Categories on Detailed Page In reply to
Hi,

Not sure I 100% understand what you're asking for,
but I'll give it a go <G>

Code:
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;
}

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] Custom Global - Listing Only Certain Categories on Detailed Page In reply to
Very close,

I've added the global you provided, and you can see the result here: Where to Work in Canada? And you're very close.
When you click on the links, you can see that they do not work properly. For some reason they keep sending me to,
http://www.policy.ca/directory/CFG-%3E%7Bbuild_root_url%7D/Labour_and_Markets/Policy_Publications/Working_Conditions/index.html

Also, would it be possible to not list "Policy Publications" category where the link is located or the yearly sub-categories (eg. "2005") in the output? I just want the sub-categories that fall between Policy Publications and the Yearly sub-categories. Am I confusing you yet? ;)

Each link is placed into as many main categories (they are located here: http://www.policy.ca/issues/directory/) are it relates to, but for each main category there are a number of sub-categories. For example, The Where to Work in Canada is located in two main categories, Children and Family and Labour and Markets, so the link is placed into both these main categories. But the link also belongs in a few sub-category. The Where to Work in Canada also belongs in the following sub-categories - [Children and Family: Standard of Living] and [Labour and Markets: Working Conditions], [Labour and Markets: Wages and Benefits]. Those additional sub-categories are broken down further into years, 2005, 2004, 2003, etc

So is it possible to list only the sub-categories that the link belongs to without going into the yearly sub-sub-categories? So in this case, the global would output,

Working Conditions
Wages and Benefits
Standard of Living

So basically what is already happening, but minus the Policy Publication and 2005 link?

Thanks for the help so far,


- Greg -
Quote Reply
Re: [mapleleafweb] Custom Global - Listing Only Certain Categories on Detailed Page In reply to
Hi,

Ooops.. this;

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

..should be;

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

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!