The following warnings occurred:
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message



GetSimple Support Forum
Test if page has children - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16)
+--- Thread: Test if page has children (/showthread.php?tid=3127)



Test if page has children - Cerulean - 2012-04-27

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
else
...some other content

Thanks.


Test if page has children - Cerulean - 2012-04-27

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

Code:
<?php
$kids = getChildren(return_page_slug());
if (!empty($kids)) {
    
...do some stuff

}
?>



Test if page has children - Carlos - 2012-04-27

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

(for GS 3.1+)


Test if page has children - Cerulean - 2012-04-27

Thanks Carlos, that's tidier.


Test if page has children - Carlos - 2012-04-27

Your way is also valid, I hadn't seen your post. :-)