GetSimple Support Forum
get_grandparent ?! - Printable Version

+- GetSimple Support Forum (
+-- Forum: GetSimple (
+--- Forum: General Questions and Problems (
+--- Thread: get_grandparent ?! (/showthread.php?tid=7511)

get_grandparent ?! - stwneu - 2015-08-27

Hi all!

I'm usually calling my sidebars with something like:

PHP Code:
<?php if (get_parent(0)=='test' or return_page_slug()=='test'get_component('sidebar-test') ; ?>

Now I have a section where I have grandchildren and even grand-grand-children, which should also have the same sidebar. Since there isn't something like "get_grandparent", do you have a hint for me?


RE: get_grandparent ?! - bluzer - 2015-08-28

Correct me if I am wrong but wouldn't/doesn't
<?php if (return_page_slug()=='page you want the side bar on' ) get_component('sidebar-name') ;?>
work - or do you have pages with the same name under different "parents"?

RE: get_grandparent ?! - stwneu - 2015-09-02

That's right, but if I would do it this way, I would have to add a lot of pages, which is, why I'm looking for another way Undecided

RE: get_grandparent ?! - Everyone - 2015-09-02

If I understand correctly, you'd like to have something like:

PHP Code:
<?php if( hasParent('test') || return_page_slug() == 'test'get_component('sidebar-test'); ?>


RE: get_grandparent ?! - stwneu - 2015-09-02

(2015-09-02, 18:23:18)Everyone Wrote: If I understand correctly, you'd like to have something like:

PHP Code:
<?php if( hasParent('test') || return_page_slug() == 'test'get_component('sidebar-test'); ?>


To visualize it a little: 
I would like to add a certain sidebar to all children of "Main Element 2". If we have only one sub-level (Second level), the script I posted originally works just fine. But then "Third level" does not have the same sidebar.
  • Main Element 1 
  • MainElement 2
    - Second level
       - Third level
  • Main Element 3

RE: get_grandparent ?! - Carlos - 2015-09-02

Perhaps this: