GetSimple Support Forum

Full Version: Test if page has children
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can anyone suggest a PHP snippet that will test if the current page has children?

My aim is to make a section of my template conditional on the page having children:
if has children
...some content
...some other content

The below works, but would be interested to hear if there's a better way. I'm a PHP beginner.

$kids = getChildren(return_page_slug());
if (!empty($kids)) { some stuff

<?php if (count(getChildren(return_page_slug())) > 0) { ?>
<?php } else { ?>
<?php } ?>

(for GS 3.1+)
Thanks Carlos, that's tidier.
Your way is also valid, I hadn't seen your post. :-)