Menu placed outside pagelayout.tpl

Author Message

Salvatore Guarino

Friday 02 September 2005 4:30:50 am

I have to place this menu in a custom template, (i.e. my_product.tpl), but the variable '<i>$module_result</i>' in this namespace is unknown. There is another way? Can I use another variable?

<ul>
{def $mainMenu=treemenu( $module_result.path, $module_result.node_id, array('folder','folder_product','tire_chain'), 1, 6)}
{foreach $mainMenu as $menu}
    <li class="level_{$menu.level}">	
    {if $menu.is_selected}
        <div class="selected">
        <a href={$menu.url_alias|ezurl}>{$menu.text}</a>
        </div>
    {else}
        <a href={$menu.url_alias|ezurl}>{$menu.text}</a>
    {/if}
 
    </li>
{/foreach}
    </ul>

Stig Tidemandsen

Tuesday 25 October 2005 3:48:57 am

I'm having the same problem.
Is there any way to make $module_result.path or an equivalent array available within $module_result.content?

Kristof Coomans

Thursday 27 October 2005 12:58:45 am

Are you including this template in pagelayout.tpl, or somewhere else?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Łukasz Serwatka

Thursday 27 October 2005 1:03:49 am

Stig, there is $node.path_array which holds node ids.

you can loop throw this array like

{foreach $node.path_array as $item}
    {def $node_data=fetch( content, node, hash( node_id, $item ) )}
    {$node_data.name}
{/foreach}

Or just use $node.path this array contains content objects. Check it {$node.path|attribute(show,1)}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Stig Tidemandsen

Thursday 27 October 2005 1:18:49 am

Thanx for the reply Lukasz However... The actual problem isn't looping the array, but doing the treemenu fetch.

<b>Usage</b>

treemenu( path, 
          node_id
          [, class_filter ]
          [, depth_skip   ]
          [, max_level    ] )

The examples in the documentation use $module_result.path for the path argument. This means that I can't use treemenu outside pagelayout, unless I have a substitute for $module_result.path avaliable.

It would be nice to be able to use treemenu outside pagelayout because it simplifies determening if the node / parent node / grandparent node and so on, is selected:

{foreach $treemenu as $menuitem}
	<div style="margin-left:{$menuitem.level|mul(7)}px">
		<a {$menuitem.is_selected|choose('','class="selected"')} href={$menuitem.url_alias|ezurl}>
			{$menuitem.text} 
		</a>
	</div>
{/foreach}

Łukasz Serwatka

Thursday 27 October 2005 1:42:40 am

You are right, but you can use node.path or node.path_array as workaround and build menu without treemenu operator usling list or tree, more complicated but still possible ;)

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Łukasz Serwatka

Thursday 27 October 2005 1:50:11 am

Look here
http://ez.no/products/ez_publish_cms/documentation/customization/tips_tricks/creating_tree_menus

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

H-Works Agency

Wednesday 07 December 2005 7:10:47 pm

Here is how i use 'treemenu' out of pagelayout.tpl (thus without $module_result.path) :

<b>The concept is to recreate the same $module_result.path array available in pagelayout.tpl.</b>

{def $module_path=array()}
      {foreach $node.path_array|remove(0,1) as $element}
      {def $thisnode=fetch('content', 'node', hash('node_id',$element))}
      {def $thisArray=hash('text', $thisnode.name, 'url', concat('/content/view/full/',$thisnode.node_id), 'url_alias', $thisnode.url_alias, 'node_id', $thisnode.node_id)}
      {set module_path=$module_path|append($thisArray)}
      {undef $thisnode $thisArray}
      {/foreach}

Then you just have to go on with the classical function synthax :

{let docs=treemenu($module_path,(...))}

</code>

EZP is Great

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.