GetSimple Support Forum

Full Version: get_grandparent ?!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?

Thanks!
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"?
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
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'); ?>

?
(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