[Solved] Tag or UDT for total page count?
[Solved] Tag or UDT for total page count?
Can anyone suggest a core tag or UDT that would give the total number of pages in the website?
Thanks.
Thanks.
Last edited by Cerulean on Wed Oct 30, 2013 8:49 am, edited 1 time in total.
Re: Tag or UDT for total page count?
MenuManager module has a counter for active pages inside which you can use.
Re: Tag or UDT for total page count?
Thanks, but can you elaborate a bit?
Do you mean I can create a custom Menu Manager template that would output just the total count of active pages? I don't see a parameter for the {menu} tag that would do this.
Do you mean I can create a custom Menu Manager template that would output just the total count of active pages? I don't see a parameter for the {menu} tag that would do this.
Re: Tag or UDT for total page count?
Ok, my fault - meant Smarty has a total counter for foreach loops 
http://www.smarty.net/docs/en/language. ... oreach.tpl
http://www.smarty.net/docs/en/language. ... erty.total
You dont need an additional MenuManager template. It's only the question where you want to output the counter. The variable is everytime available
.
With this foreach opening in default MenuManager template
Thats all.
Note: node (or something other) must be unique.

http://www.smarty.net/docs/en/language. ... oreach.tpl
http://www.smarty.net/docs/en/language. ... erty.total
You dont need an additional MenuManager template. It's only the question where you want to output the counter. The variable is everytime available

With this foreach opening in default MenuManager template
you have only to add{foreach from=$nodelist item=node}
on the place of output.{$node@total}
Thats all.
Note: node (or something other) must be unique.
Re: Tag or UDT for total page count?
Thanks chandra, works great.
To spell it out...
Create a new Menu Manager template called "page_count":
In your page template or page:
or
To spell it out...
Create a new Menu Manager template called "page_count":
Code: Select all
{foreach from=$nodelist item=node}
{/foreach}
{$node@total}
Code: Select all
Total active pages in menu: {menu template="page_count"}
Code: Select all
Total active pages: {menu template="page_count" show_all="1"}
Last edited by Cerulean on Wed Oct 30, 2013 9:00 am, edited 1 time in total.
Re: Tag or UDT for total page count?
You could try this:
Create a UDT called PageCounter
In the page you add {PageCounter}
Create a UDT called PageCounter
Code: Select all
$db = cmsms()->GetDb();
$query = "SELECT count(content_id) FROM " . cms_db_prefix() . "content WHERE active=1";
$result = $db->Execute($query);
$row = $result->FetchRow();
echo ($row['count(content_id)']);
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Re: [Solved] Tag or UDT for total page count?
Cheers Rolf, that works well too.
I tried your UDT alongside the {menu} solution on one of my sites and the UDT counts 1 extra page, which is interesting. I think the UDT must include pages of the "Error Page" content type in the count whereas the {menu} solution does not.
I tried your UDT alongside the {menu} solution on one of my sites and the UDT counts 1 extra page, which is interesting. I think the UDT must include pages of the "Error Page" content type in the count whereas the {menu} solution does not.
Re: [Solved] Tag or UDT for total page count?
CorrectYou could also add/change in line 3
Code: Select all
$db = cmsms()->GetDb();
$query = "SELECT count(content_id) FROM " . cms_db_prefix() . "content WHERE type='content' AND active=1";
$result = $db->Execute($query);
$row = $result->FetchRow();
echo ($row['count(content_id)']);
Code: Select all
AND show_in_menu=1
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Re: Tag or UDT for total page count?
If you only have a single menu on your website you dont need an additional MenuManager call.Cerulean wrote: To spell it out...
Create a new Menu Manager template called "page_count":Code: Select all
{foreach from=$nodelist item=node} {/foreach} {$node@total}
You can insert
Code: Select all
{$counter = $node@total}
With {$counter} you can call now page value where ever you want.
Be aware every additional module call or udt call slows down the performance of your website.