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

Total number of links in specific category on home page

Quote Reply
Total number of links in specific category on home page
Hello

Does anyone have a working global that will do the following:

Dispaly a total number of links in (a certian category and all its subs) on the home page, so we can list something like:

Articles (250 article) on the home page.

were articles is not a top category and the number 250 represents the total numbers in Articles and all its sub categories.
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Total number of links in specific category on home page In reply to
Yes, I have created this some month ago. You probably need to change the return number of links. Curently, there is just 5 records are returned

Code:
sub {
my $db = $DB->table('Links');

$db->select_options("Order by Add_Date Desc");
$db->select_options("Limit 5");
my $rs = $db->select({isValidated => 'Yes'})->fetchall_hashref;
return unless(defined $rs);
my $output ="";
foreach(@$rs){
$output .= Links::SiteHTML::display(\'link',$_);
}
return $output;
}

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Total number of links in specific category on home page In reply to
Hello Dat

I think you misunderstood me.

I just want to show the number of links in the category and not the links themselves..
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Total number of links in specific category on home page In reply to
You are right. I have copied the wrong global.

I hope someone else has done this

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog

Last edited by:

tandat: Apr 23, 2006, 8:36 PM
Quote Reply
Re: [katabd] Total number of links in specific category on home page In reply to
Just dropping this here in case someone else finds this thread. Smile

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

Call with <%global_name('X')%> where X is the ID of the category you want to show.

Safe swoops
Sangiro
Quote Reply
Re: [katabd] Total number of links in specific category on home page In reply to
or you could just use <%category_loop.length%>...

Hope this helps,

---------------------------

never mind, just realized you were talking about its subs also...

- Jonathan

Last edited by:

jdgamble: Sep 25, 2006, 12:08 PM
Quote Reply
Re: [jdgamble] Total number of links in specific category on home page In reply to
<%category_loop.length%> is the number of subcategories displayed...

<%Number_of_Links%> will give you the total number of links in the currently displayed category and it's subcategories. <%Direct_Links%> is the number of links NOT including it's subcategories.

No globals are required for this... these tags are available by default.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Total number of links in specific category on home page In reply to
I knew there was an easy way to do it Wink

- Jonathan
Quote Reply
Re: [fuzzy logic] Total number of links in specific category on home page In reply to
Quote:
No globals are required for this... these tags are available by default.

The original question was to include this information for a specific category on the home page.

The intention of the global above is to enable you to target any category, regardless of how deep it is buried into your tree structure and display the number of links in that category (including subs) on any page.

I'd be curious to see how that can be done without a global. Wink

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Total number of links in specific category on home page In reply to
Blush
There's no question that you can't arbitrarily use those tags... I just interpreted the question differently to mean he wanted the numbers for the displayed category, not for a list of random categories displayed somewhere on a random page, using the homepage as an example of the result wanted.

Philip
------------------
Limecat is not pleased.