Page 1 of 1

How to access page_start variable in Navigator

Posted: Tue Jan 30, 2018 7:11 pm
by MZTech
How do I access the start_page variable set in {Navigator start_page="TEST"} inside Navigator::Navigation template?

Re: How to access page_start variable in Navigator

Posted: Wed Jan 31, 2018 10:21 am
by PinkElephant
Hi MZTech

There's nothing doing in {$nodes|print_r} but {get_template_vars} shows a way:

Code: Select all

<h3>DEBUG: start_page={$actionparams['start_page']|default:'(not specified)'}</h3>

Re: How to access page_start variable in Navigator

Posted: Wed Jan 31, 2018 11:51 am
by MZTech
Thank you very much. It worked.
Didn't know about {get_template_vars}.

How did you extract that DEBUG: start_page?

When I use {get_template_vars} I dont see start_page.

Re: How to access page_start variable in Navigator

Posted: Wed Jan 31, 2018 12:59 pm
by PinkElephant
With {get_template_vars} in the Nav template you should have seen something like:

Code: Select all

$actionparams (array) = [
   .template (string) = Example v02 - Nav submenu DEBUG
   .start_page (string) = test
   .childrenof (string) = testbed
   .show_all (integer) = 1
   .loadprops (integer) = 0
   .module (string) = Navigator
   .action (string) = default
]
... which shows the actionparams array and its keys -- including start_page, when set.

Aside: I wanted to get print_r and {get_template_vars} out there but a more normal approach might be to set a var in the calling template:

Code: Select all

{$jolly_green_giant='test'}
{Navigator start_page=$jolly_green_giant} 
... then $jolly_green_giant should be available in the Navigator template (if not, try {$jolly_green_giant='test' scope=global}). This approach is slightly less efficient but probably easier to read/maintain.

Re: How to access page_start variable in Navigator

Posted: Wed Jan 31, 2018 1:08 pm
by MZTech
Thank you again for all the information. It was very helpful.

Re: How to access page_start variable in Navigator

Posted: Thu Feb 01, 2018 9:01 am
by rotezecke
start_page="" - Starts the menu displaying at the given start_page and showing that element and it's children only. Takes a page alias.
Based on that description, I have a feeling that start_page is always equal to {$nodes[0]->alias}. Untested though.