Gossamer Forum
Quote Reply
Global: Number of link
Hi,



I need to write the list of categories with the number of links inside each category in any page. Like this:



category1 (16)

category2 (65)

category3 (2)





The html code would be:



<p>category1 (<%Number_of_link_1%>)</p>

<p>category2 (<%Number_of_link_2%>)</p>

<p>category3 (<%Number_of_link_3%>)</p>





Would anyone know how to make <%Number_of_links_ID%> as a global variable in HTML_Templates.



Thanks in advance
Quote Reply
Re: [JoseML] Global: Number of link In reply to
I'm not sure. Try <%count%>

If all else fails, try using <%GT::Template::dump%>, which will give you a list of all the available tags, and their values.

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] Global: Number of link In reply to
Thanks Andy, but I tried <%GT::Template::dump%> and I did not find the global that I need.

I think that I need a global <%Number_of_links_ID%> for each category.

Thanks again.

JoseML
Quote Reply
Re: [JoseML] Global: Number of link In reply to
How do you load the category information on your template?

You will have to use a global that loads the category information as a loop. You can then use this loop to display the name of the category, but also the number of links in it .

Use this global (get_category_loop):
Code:
sub {
return { category_loop => $DB->table('Category')->select()->fetchall_hashref }
}
On your template, use
Code:
<%loop category_loop%>
<%Name%> (<%Number_of_Links%>)
<%endloop%>
Code:

I hope this helps.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Global: Number of link In reply to
Thanks Ivan, i tried your global but it didnt work.

I didnt explain myself well. I dont need a list of categories with Number_of_links. I just need "Number_of_links" of a category.

The glogal that i need i wish to be written like this:

Category154 (<%Number_of_Links(154)%>)

that will result in: Category154(342)

"Category154" isn't a tag.

Ive tried this but it didnt work:

sub { return $DB->table( 'Category' )->count( { 'Number_of_Links' => ID } ); }


Could someone help me?.

Thanks in advance.
Quote Reply
Re: [JoseML] Global: Number of link In reply to
I think it needs to be more like this.

sub {

my $id=shift;

return $DB->table( 'Category' )->select( ['Number_of_Links'],{ID=>$id} )->fetchrow_array;

}
Quote Reply
Re: [afinlr] Global: Number of link In reply to
Thanks a lot Afinlr, the global works fine.

Last edited by:

JoseML: Aug 2, 2003, 5:56 PM