A very simple snippet for GetSImple CMS to have a function to make conditionals. It checks if the current page, its parent or its grandparent has a certain slug (page identifier).
It doesn't work beyond 2 levels (not for great-grandchild pages)
Put this in your theme's functions.php file (create it if doesn't exist)
<?php
function page_or_ancestor_is($slug='') {
return ( (get_parent(false) != '' && returnPageField(get_parent(false),'parent') == $slug)
|| get_parent(false) == $slug
|| return_page_slug() == $slug
);
}
// end
Usage: in template or component, insert:
<?php if (page_or_ancestor_is('page-slug')) {?>
The conditional html/code/text...
<?php } ?>
(first posted here)
blog comments powered by Disqus