Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Re: tags to non "Links" table

Quote Reply
Re: tags to non "Links" table In reply to
Hi,

First off, just a little context here. This function will be saved in the Template Globals as:

tag_name => sub { .. }

in the admin. Now when you use <%tag_name%> in any template, it will run the given function.

my $tags = shift;

The first argument to the function will be the list of other tags on the template. So if you had <%tag_name%> in the link.html template, in $tags would be a hash of all the fields available in link.html.

my $link_id = $tags->{ID} or return;

This assumes that on the template you are using, you have the ID number of the link you want. This may be wrong, as I'm not sure exactly what you are doing. If there is no ID tag on this page, then we return as there is not much we can do.

my $catlnk_db = $DB->table('CatLinks');

This gives you a GT::SQL::Table object that works off of the CatLinks table.

my $sth = $catlnk_db->select ( { LinkID => $link_id } );

This selects out of the database the row where LinkID = the ID on this template.

my $results = $sth->fetchrow_hashref;

This returns the results as a hash. So it would look like { LinkID => 5, CategoryID => 3, CustomColumn => ... }.

You can now either return what you want printed, or if you just return the hash, then you will have <%LinkID%>, <%CategoryID%> and <%CustomColumn%> tags available on the page.

Let me know if this makes sense,

Cheers,

Alex

--
Gossamer Threads Inc.
Subject Author Views Date
Thread tags to non "Links" table dwh 2435 May 21, 2001, 1:36 AM
Thread Re: tags to non "Links" table
Alex 2372 May 22, 2001, 1:11 PM
Thread Re: tags to non "Links" table
dwh 2364 May 22, 2001, 9:29 PM
Thread Re: tags to non "Links" table
Alex 2344 May 23, 2001, 10:25 AM
Thread Re: tags to non "Links" table
dwh 2346 May 23, 2001, 11:55 AM
Thread Re: tags to non "Links" table
Alex 2365 May 23, 2001, 12:00 PM
Thread Re: tags to non "Links" table
dwh 2307 May 24, 2001, 10:01 PM
Post Re: tags to non "Links" table
Alex 2289 May 27, 2001, 8:27 PM