Author Topic: ShowMenu2: Display root level page + child pages from any page  (Read 3755 times)

Offline CodeALot

  • Posts: 506
  • Gender: Male
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?

Offline nibz

  • Posts: 684
  • Gender: Male
Re: ShowMenu2: Display root level page + child pages from any page
« Reply #1 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.

Offline CodeALot

  • Posts: 506
  • Gender: Male
Re: ShowMenu2: Display root level page + child pages from any page
« Reply #2 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! :-)

Offline Gast

  • Posts: 5920
Re: ShowMenu2: Display root level page + child pages from any page
« Reply #3 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



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  ;-)

Offline CodeALot

  • Posts: 506
  • Gender: Male
Re: ShowMenu2: Display root level page + child pages from any page
« Reply #4 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



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.

Offline sky writer

  • Posts: 926
Re: ShowMenu2: Display root level page + child pages from any page
« Reply #5 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.

Offline CodeALot

  • Posts: 506
  • Gender: Male
Re: ShowMenu2: Display root level page + child pages from any page
« Reply #6 on: April 18, 2016, 09:24:36 AM »
Thanks, I'll give that one a try too :)

Offline sky writer

  • Posts: 926
Re: ShowMenu2: Display root level page + child pages from any page
« Reply #7 on: May 13, 2016, 02:14:14 AM »
Did that solution work for you?

Offline CodeALot

  • Posts: 506
  • Gender: Male
Re: ShowMenu2: Display root level page + child pages from any page
« Reply #8 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 :)

Offline sky writer

  • Posts: 926
Re: ShowMenu2: Display root level page + child pages from any page
« Reply #9 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>');?>










Is that not what you needed?

 

postern-length