[solved] Check if page has children pages?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
lampsie
Forum Members
Forum Members
Posts: 38
Joined: Fri Nov 17, 2006 9:25 am

[solved] Check if page has children pages?

Post by lampsie »

Hi,

This seems like a simple query but a google and search on forums here has not yielded an answer for me :)

In my site template, I want to check and see if the page I am currently on has children pages. Is it possible to do this? NOTE: this is outside of the menu manager module etc, just within the smarty template itself.

What I am trying to do: Using some kind of {if} statement, if page has menu I want to use certain DIV's, if not I want to use others. It will save me needing to create two manual templates.

Thanks,
Lampsie
Last edited by lampsie on Thu Apr 23, 2009 9:15 am, edited 1 time in total.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Check if page has children pages?

Post by RonnyK »

CGSimpleSmarty has some calls to check this IIRC... You could check its help to see what it can return....

Ronny
lampsie
Forum Members
Forum Members
Posts: 38
Joined: Fri Nov 17, 2006 9:25 am

Re: [solved] Check if page has children pages?

Post by lampsie »

RonnyK, thank you, that solved it :)
For the record:

1) Installed CGSimpleSmarty
2) In my template, used this to figure out if page has children or not:

{if $cgsimple->has_children('',$has_children) eq 1}Has children{else}No children{/if}

If you want to check if this page has children OR if it has a parent (which is what I needed in the end):
{if $cgsimple->has_children('',$has_children) eq 1 or $cgsimple->get_parent_alias() neq "" }

Thanks very much,
Lampsie
Last edited by lampsie on Thu Apr 23, 2009 9:39 am, edited 1 time in total.
Post Reply

Return to “CMSMS Core”