I could find no global on a links detail page that would give a cross-reference to the category under which the link is located. The only thing I could think of is to parse the <%title%> tag which contains the category in it. Is there a more direct way to get the 'first level' up category associated with a link on this page?
Aug 27, 2003, 1:15 AM
Veteran / Moderator (18436 posts)
Aug 27, 2003, 1:15 AM
Post #2 of 6
Views: 2387
Something like this should work;
my $ID = shift;
my (@_ids,@cat_titles);
my $table = $DB->table('CatLinks');
my $sth = $table->select( { LinkID => $ID } );
while (my $hit = $sth->fetchrow_hashref) {
push(@_ids,$hit->{CategoryID});
}
foreach (@_ids) {
my $table = $DB->table('Category');
my $sth = $table->select( { ID => $_ } );
while (my $hit = $sth->fetchrow_hashref) {
push(@cat_titles,$hit->{Title});
}
}
return join(", ",@cat_titles);
}
Call it with something like;
<%global_name($ID)%>
Untested, but the theory is beind it (if it doesn'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!
Code:
sub { my $ID = shift;
my (@_ids,@cat_titles);
my $table = $DB->table('CatLinks');
my $sth = $table->select( { LinkID => $ID } );
while (my $hit = $sth->fetchrow_hashref) {
push(@_ids,$hit->{CategoryID});
}
foreach (@_ids) {
my $table = $DB->table('Category');
my $sth = $table->select( { ID => $_ } );
while (my $hit = $sth->fetchrow_hashref) {
push(@cat_titles,$hit->{Title});
}
}
return join(", ",@cat_titles);
}
Call it with something like;
<%global_name($ID)%>
Untested, but the theory is beind it (if it doesn'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!
Aug 27, 2003, 8:29 AM
User (150 posts)
Aug 27, 2003, 8:29 AM
Post #3 of 6
Views: 2369
Cool, I did it the lazy way for now :)
sub {
# gets the category of this link on the link detail page by parsing the title variable
my $title = shift;
my @fields = split(/:/, $title);
my $cat = @fields[1];
for ($cat) {
s/^\s+//;
s/\s+$//;
}
return $cat;
}
sub {
# gets the category of this link on the link detail page by parsing the title variable
my $title = shift;
my @fields = split(/:/, $title);
my $cat = @fields[1];
for ($cat) {
s/^\s+//;
s/\s+$//;
}
return $cat;
}
Aug 27, 2003, 8:41 AM
Veteran / Moderator (18436 posts)
Aug 27, 2003, 8:41 AM
Post #4 of 6
Views: 2370
Not sure how that is meant to work.. but if it does, then by all means, use it
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!

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!
Aug 27, 2003, 8:57 AM
User (150 posts)
Aug 27, 2003, 8:57 AM
Post #5 of 6
Views: 2352
The <%title%> global is available on each link page. Take a look at it, it is a concatenation of the category (e.g. TopLevel:SecondLevel:thirdlevel)
So this just splits that string into an array, cleans it up for whitespaces, and then gets what you want
So this just splits that string into an array, cleans it up for whitespaces, and then gets what you want
Aug 27, 2003, 9:01 AM
Veteran / Moderator (18436 posts)
Aug 27, 2003, 9:01 AM
Post #6 of 6
Views: 2354
If my global works, I would recommend using that. Your global will not work with multiple categories assigned to a link. My one should do that just 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!
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!