Gossamer Forum
Quote Reply
Category under each link
I am using the following global to display the category under each link, the url output points to the category index.html. But I have now changed the build name to directory.html (need to do this as I also run another program in root which has a index.html)

can the code be changed to point to directory.html ?

sub {
my $id = shift;
my $cat_db = $DB->table('Category');
my $catlink = $DB->table('CatLinks','Category');
my @names = $catlink->select ({ LinkID => $id }, ['Full_Name'])->fetchall_list;

my @link_cats;
for (@names) {

push @link_cats, { cat_name => Links::Build::build ('title_unlinked',$_), cat_url => $cat_db->as_url($_)};
}
return { link_cats => \@link_cats };



----------

Thanks

Cat
Quote Reply
Re: [cat] Category under each link In reply to
Ok Found the solution, needed to change the template.. works now!

---------

Cat
Quote Reply
Re: [cat] Category under each link In reply to
What is your solution?

Thanks Smile

------------------------------------------
Quote Reply
Re: [DogTags] Category under each link In reply to
Hi there! Smile

The global is called get_links_cats (many thanks to the member who posted this global in the forums)

in the newlink template add your target page after <%cat_url%>

it should look like the following..

<%get_link_cats($ID)%> <%loop link_cats%>

<a href="http://www.yoursite.com/<%cat_url%>/directory.html">

<%cat_name> <%endloop%>





where /directory.html is target page (change to your page name)



hope this helps



----------

Cat
Quote Reply
Re: [cat] Category under each link In reply to
I wanted it to copy build_linked_title so I wrote this:

Code:

'category' => 'sub {
my $tag = shift;
my $table = $DB->table (\'CatLinks\');
my $sth = $table->select ( { LinkID => $tag->{ID} }, [\'CategoryID\'] );
my $catID = $sth->fetchrow();
my $cattable = $DB->table(\'Category\');
my $sth2 = $cattable->select ( { ID => $catID }, [\'Full_Name\'] );
my $name = $sth2->fetchrow_array;
my @dirs = split (/\//, $name);
my $output = qq| <a href="$CFG->{build_root_url}/$CFG->{build_index}">Home</a>&nbsp;>|;
for (0 .. $#dirs) {
my $path = "/" . $cattable->as_url( join "/", @dirs[0 .. $_] );
$output .= qq| <a href="$CFG->{build_root_url}$path/$CFG->{build_index}">$dirs[$_]</a>&nbsp;>|;
}
return $output;
}',


and in links.html I put

You can look at build_linked_title in build.pm if you need more options...

<%if query%>
<%category%>
<%endif%>

Hope this helps anyone...

- Jonathan