WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: CodeALot on April 14, 2016, 02:01:58 PM

Title: ShowMenu2: Display root level page + child pages from any page
Post by: CodeALot on April 14, 2016, 02:01:58 PM
I'm probably overlooking something but I can't find it:

I want to display a page-tree from a specific page (say PAGE_ID 5) and the child pages of that specific page.

I know about this solution:
Code: [Select]
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_CURRTREE); but that will only show the page tree of the page I am on at that moment.

What I want is: to show the pagetree of PAGE_ID 5 on any other page as well.

Any ideas?
Title: Re: ShowMenu2: Display root level page + child pages from any page
Post by: nibz on April 14, 2016, 02:18:45 PM
Maybe this works?:
Code: [Select]
show_menu2(0, 5, SM2_ALL, SM2_ALL);

Where 5 is the PAGE_ID of the page you want to use as root for the menu.
Title: Re: ShowMenu2: Display root level page + child pages from any page
Post by: CodeALot on April 14, 2016, 02:23:37 PM
Maybe this works?:
Code: [Select]
show_menu2(0, 5, SM2_ALL, SM2_ALL);

Where 5 is the PAGE_ID of the page you want to use as root for the menu.

Hi Nibz,

Well, that is a start since it shows all the child pages of page 5, but not page 5 itself :) But I could solve that with a second call of the menu, showing only root level. Thanks for getting me going again! :-)
Title: Re: ShowMenu2: Display root level page + child pages from any page
Post by: Gast on April 14, 2016, 02:29:45 PM
Do you mean a second menu??  if yes, use the page_id from your start-page instead of SM2_ROOT like this example here

(https://i.gyazo.com/e3f4ac55dd6293d91f32140f71840c39.png)

549 is the id of my parent of this 3 subpages, here called as "CDs"
and the second menu is theresult of this menu call here
Code: [Select]
<?php show_menu2(0549SM2_ALLSM2_ALL,'<li><span class="menu-default">[ac][menu_title]</a></span>','</li>','<ul>','</ul>');?>
Upp, too late  ;-)
Title: Re: ShowMenu2: Display root level page + child pages from any page
Post by: CodeALot on April 14, 2016, 02:33:55 PM
Do you mean a second menu??  if yes, use the page_id from your start-page instead of SM2_ROOT like this example here

(https://i.gyazo.com/e3f4ac55dd6293d91f32140f71840c39.png)

549 is the id of my parent of this 3 subpages, here called as "CDs"
and the second menu is theresult of this menu call here
Code: [Select]
<?php show_menu2(0549SM2_ALLSM2_ALL,'<li><span class="menu-default">[ac][menu_title]</a></span>','</li>','<ul>','</ul>');?>
Upp, too late  ;-)

Help is never too late :)

What I mean is that I want to have a pagetree/menu displaying:

CD's
* CD 1
* CD2
* CD3


on *any* page. So just the pagetree of CD's, including the top level.
Title: Re: ShowMenu2: Display root level page + child pages from any page
Post by: sky writer on April 18, 2016, 06:09:38 AM
I'm sure you got this figured out by now, but if not, I worked out a simple solution:
Code: [Select]
<?php show_menu2(089SM2_ALLSM2_ALL,'<li><span class="menu-default">[ac][menu_title]</a></span>','</li>','<ul>','</ul>');?>
The trick is, 89 is the id of an unused "hidden" (dummy) root parent page of "CDs".  This way the child page "CDs" is shown, and then all children of the CDs page are shown as well.

Hope this helps.
Title: Re: ShowMenu2: Display root level page + child pages from any page
Post by: CodeALot on April 18, 2016, 09:24:36 AM
Thanks, I'll give that one a try too :)
Title: Re: ShowMenu2: Display root level page + child pages from any page
Post by: sky writer on May 13, 2016, 02:14:14 AM
Did that solution work for you?
Title: Re: ShowMenu2: Display root level page + child pages from any page
Post by: CodeALot on May 13, 2016, 10:17:49 AM
Unfortunately no. I ended up creating different menu-'numbers' for every pagetree and calling them using  show_menu2(1  /  show_menu2(2  /  show_menu2(3 etc. etc.
For this project that worked well enough :)
Title: Re: ShowMenu2: Display root level page + child pages from any page
Post by: sky writer on May 13, 2016, 03:35:00 PM
Good enough.  Maybe I did not understand your needs.  The solution I posted does this:

What I mean is that I want to have a pagetree/menu displaying:

CD's
* CD 1
* CD2
* CD3


on *any* page. So just the pagetree of CD's, including the top level.

In this example, the hidden root page is id3:
<?php show_menu2(0, 3, SM2_ALL, SM2_ALL,'<li><span class="menu-default">[ac][menu_title]</a></span>','</li>','<ul>','</ul>');?>


(https://i.gyazo.com/7e45678890475eefa066449be11e5ade.png)

(https://i.gyazo.com/d4c5ab4c44808eeeda46b45a68887eab.png)


(https://i.gyazo.com/d7f103eb9bf199d770cde36f2c6e3b58.png)


Is that not what you needed?