Page 1 of 1

[solved] Check if page has children pages?

Posted: Wed Apr 22, 2009 5:03 pm
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

Re: Check if page has children pages?

Posted: Wed Apr 22, 2009 5:05 pm
by RonnyK
CGSimpleSmarty has some calls to check this IIRC... You could check its help to see what it can return....

Ronny

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

Posted: Thu Apr 23, 2009 9:16 am
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