Menu attributes

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Smeleck
Forum Members
Forum Members
Posts: 19
Joined: Tue Aug 14, 2018 6:35 pm

Menu attributes

Post by Smeleck »

Can someone explain how to use the Extra Page Attribute 1
I would like to add a further message on the menu.

The system is the latest version and I am using theme bandb.

Thanks
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1609
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Menu attributes

Post by DIGI3 »

You can call it in a page template using page_attr, {page_attr key="extra1"}

Or in a Navigator template, $node->extra1

If you're using it in a Navigator template, you need to make sure you aren't using loadprops=0 when you call it.
Not getting the answer you need? CMSMS support options
Smeleck
Forum Members
Forum Members
Posts: 19
Joined: Tue Aug 14, 2018 6:35 pm

Re: Menu attributes

Post by Smeleck »

Hi Thanks for info.
Can these links go anywhere in the template or in a certain place?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Menu attributes

Post by calguy1000 »

the {$node->extra1} data is only available in Navigator templates.

{page_attr} is usable everywhere. it's a standard plugin. There is help available for it in Extensions >> tags.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Menu attributes

Post by velden »

EDIT: noticed too late DIGI3 already mentioned this.

Additionally: read the help of the Navigator module. Is has a parameter loadprops.
(optional) loadprops="" - Use this parameter when NOT using advanced properties in your navigator template. This will disable the loading of all of the content properties for each node (such as extra1, image, thumbnail, etc.). This will dramatically decrease the number of queries required to build a navigation, and increase memory requirements, but will remove the possibility for much more advanced displays
You wouldn't be the first user desperately looking for the extra1 attribute to eventually find out this loadprops parameter is set to false in the {Navigator...} tag.
Smeleck
Forum Members
Forum Members
Posts: 19
Joined: Tue Aug 14, 2018 6:35 pm

Re: Menu attributes

Post by Smeleck »

Hi Guys

This idiot needs a little more help.

Can you explain were the loadprops is set? I can not find it anywhere.

In the main template I have this set just the below the {$content}
{page_attr key="extra1"}

I have tried adding the loadprops in the template like so:
{Navigator template='bandb_topnav' number_of_levels='1' loadprops='true'}

Without loadprops it gives me the correct menu I am only showing level 1. The other levels are called on a page.

I have also tried this {Navigator loadprops="1"}
whatever I put in 1, 2, 0, true or false it completely messes up the menu.

So were the devil is the loadprops set????

There seems no way to edit the module Navigator.

Yours
Totally confused.
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1609
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Menu attributes

Post by DIGI3 »

Just don't use loadprops at all. All we were saying is that if it's there in your Navigator call, your Navigator template won't have access to the extra1 parameter.

page_attr has nothing to do with loadprops, it's a parameter for Navigator. It's explained in the Navigator help. {page_attr key=extra1} in a PAGE template will always load the extra1 field from the current page. More options are available in the tag help for page_attr.
Not getting the answer you need? CMSMS support options
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Menu attributes

Post by velden »

TIP:

If you want to know what variables/properties are available, e.g. in a Navigator template, use the print_r function/modifier to display some useful information on the page (or in the page source):

Example with extra comments in the page source (html):

Code: Select all

...
<ul>
  {foreach $nodes as $node}
     <!-- {$node|print_r} -->
    {if $node->type == 'sectionheader'}
...
Example with extra comments on the page itself (note it leads to invalid html, but heh, it's for troubleshooting)

Code: Select all

...
<ul>
  {foreach $nodes as $node}
     <pre>{$node|print_r}</pre>
    {if $node->type == 'sectionheader'}
...
Another useful tag which you can use at the top of your (Navigator) template is {get_template_vars}
Smeleck
Forum Members
Forum Members
Posts: 19
Joined: Tue Aug 14, 2018 6:35 pm

Re: Menu attributes

Post by Smeleck »

I have removed all my references to loadprops but it still doesn't show the extra1 attribute.

I do have the correct code in the template.

I have also checked the page source just in case it was hidden in someway.

What I am trying to do is show the extra1 below the menu title not on the page
menu.jpg
This is part of the menu on the page just to show what I am trying to do.
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1609
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Menu attributes

Post by DIGI3 »

Show us your Navigator template which contains the {$node->extra1} tag, and the {Navigator} call you're using to load it.
Not getting the answer you need? CMSMS support options
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Menu attributes

Post by velden »

To be sure:

Adding an value to the Extra Page Attribute 1 field of a specific page:
2019-04-17 17_26_36-Content Manager - CMSMS 2.2.9.1.png
Snippet of output of {get_template_vars} at the top of the used Navigator template. {Navigator...} tag WITHOUT loadprops parameter
2019-04-17 17_27_25-Home - CMSMS 2.2.9.1.png
Smeleck
Forum Members
Forum Members
Posts: 19
Joined: Tue Aug 14, 2018 6:35 pm

Re: Menu attributes

Post by Smeleck »

I don't have this {$node->extra1} in the nav template?

I have this in the main template {page_attr key="extra1"}

Do I need both?

This is the nav call in the main template which gives me level I only.
{Navigator template='bandb_topnav' number_of_levels='1'}

This is the call in the page
<div id="articles">{Navigator start_level=2 collapse=1}</div>
The id gives me css for the background.

The text in the page extra1 attribute is correct.

This is the nav template code straight out the box.

{strip}
{* Top Menu *}
{* drilldown for mobile, dropdown for tablet & above *}
{* see Zurb Foundation docs for other options *}

{function name=topnav}
{if $depth==0}
<ul class="vertical medium-horizontal menu" data-responsive-menu="drilldown medium-dropdown">
{else}
<ul class="menu">
{/if}
{foreach $data as $node}
{* setup classes for the anchor and list item *}
{assign var='liclass' value='menudepth'|cat:$depth}
{assign var='aclass' value=''}

{* the first child gets a special class *}
{if $node@first && $node@total > 1}{assign var='liclass' value=$liclass|cat:' first_child'}{/if}

{* the last child gets a special class *}
{if $node@last && $node@total > 1}{assign var='liclass' value=$liclass|cat:' last_child'}{/if}

{if $node->current}
{* this is the current page *}
{assign var='liclass' value=$liclass|cat:' menuactive'}
{assign var='aclass' value=$aclass|cat:' menuactive'}
{/if}

{if $node->parent}
{* this is a parent of the current page *}
{assign var='liclass' value=$liclass|cat:' menuactive menuparent'}
{assign var='aclass' value=$aclass|cat:' menuactive menuparent'}
{/if}

{if $node->children_exist}
{assign var='liclass' value=$liclass|cat:' parent'}
{assign var='aclass' value=$aclass|cat:' parent'}
{/if}

{* build the menu item node *}
{if $node->type == 'sectionheader'}
<li class='sectionheader {$liclass}'><a href="#" onclick="event.preventDefault();"><span>{$node->menutext}</span></a>
{if isset($node->children)}
{topnav data=$node->children depth=$depth+1}
{/if}
</li>
{else if $node->type == 'separator'}
<li class='separator {$liclass}'><hr class='separator'/></li>
{else}
{* regular item *}
<li class="{$liclass}">
<a class="{$aclass}" href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}><span>{$node->menutext}</span></a>
{if isset($node->children)}
{topnav data=$node->children depth=$depth+1}
{/if}
</li>
{/if}
{/foreach}
</ul>
{/function}

{if isset($nodes)}
{topnav data=$nodes depth=0}
{/if}
{/strip}
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1609
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Menu attributes

Post by DIGI3 »

Page_attr with no page defined will output the extra1 of the current page, wherever you place the tag.

If you want to output it for each page in your navigation, you need to use node->extra1 in the appropriate place of your navigator template.
Not getting the answer you need? CMSMS support options
Smeleck
Forum Members
Forum Members
Posts: 19
Joined: Tue Aug 14, 2018 6:35 pm

Re: Menu attributes

Post by Smeleck »

Hi
I now have the attribute showing but this was done by going back to using the menu call. {menu start_level='2' collapse='1' } and commenting out two bits of code in the template BandB_topnav i.e.
{* the first child gets a special class
{if $node@first && $node@total > 1}{assign var='liclass' value=$liclass|cat:' first_child'}{/if}
*}
{* the last child gets a special class
{if $node@last && $node@total > 1}{assign var='liclass' value=$liclass|cat:' last_child'}{/if}
*}
I have failed to find away to use Navigator.


I now just need to short ouit how to add css to the exra1 attribute.


Thanks fore all your help.
Post Reply

Return to “Modules/Add-Ons”