Forums / Setup & design / Possible to get a menu on system template pages this way?

Possible to get a menu on system template pages this way?

Author Message

Mark Emms

Saturday 07 July 2007 1:05:00 am

I'm still quite new to this (brilliant!!) game. Here's what I want to do - but before I spend time on it I want to check that I have understood it properly:

At the moment system templates show no menu because there is no node associated with their output (at least that's my understanding).

I would like to get the flat_left.tpl overridden by a template which does exactly the same thing but checks if there is a node and if there isn't it specifies one - perhaps the root node (but also perhaps not)

I think I either need to change this a bit:

{let docs=treemenu( $module_result.path,
                    is_set( $module_result.node_id )|choose( 2, $module_result.node_id ),
                    ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' ),
                    0, 5 )
                    depth=1
                    last_level=0}

or I need to exchange $module_result.path and $module_result.node_id for new variables ($current_path and $current_node_id perhaps) and test them to see if they have values and if they don't set them to values of my choice before this code fragment is run.

Hoping someone with more experience can give me a pointer or two!

Many thanks in advance.

Mark Emms

Monday 09 July 2007 6:09:03 am

I wonder if I've not made myself clear enough :-( ?

When I do a search or get an error page/ login etc the flat_left menu is empty - this is not good for the site I am making.

Instead of having to edit each of the system templates as described elsewhere (but not clearly enough for me I'm afraid) I want o modify the flat_menu.tpl file. I want it to check to see if a node_id has been set (or something similar) and if it hasn't I want it to set a value.

The aim is get a "default" menu that appears whenever I am getting an empty menu at the moment.

Many thanks

Mark Emms

Monday 09 July 2007 8:43:51 am

Worked it out on my own once I had the time:

used

{if is_set($module_result.node_id)}

standard menu production code

{else}

pasted code from source outputted from the node giving the default menu I wanted - from <ul> through to </ul>

{/if}

Mark Emms

Monday 09 July 2007 8:53:31 am

Would like to be able to set values for:

$module_result.node_id

and

$module_result.path

and let the treemenu do its work really - not sure if that would work though and don't know what value to enter for $module_result.path.

André R.

Tuesday 10 July 2007 1:18:20 am

As you might know you can't set objects in the template language, but if you really want to you can use a template operator to do it.

Some code that might help:

$view_parameters =& $tpl->variable('view_parameters');
$page_offset = $view_parameters['offset'];
...
$tpl->setVariable('children', $children);

But it's a lot cleaner to override pagelayout.tpl and change the logic to suite your needs!

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Mark Emms

Tuesday 10 July 2007 2:46:03 am

Thanks Andre

yes - I have used an override, I always do these days!

I'm afraid I didn't understand what you were trying to tell me with your code fragment - sorry. Please could you expand upon what you mean?

I have been reading the documentation about treemenu and module_result.

module_result.path is an array of hashes I believe.

In principle could I create an array of hashes like this:

{def $mypathinfo=array( 'text', 'Homepage', 'url', '/content/view/full/2','url_alias','home','node_id','2')}

and then feed that into the treemenu function as follows?

{let docs=treemenu( $mypathinfo,
                   is_set( $module_result.node_id )|choose( 2, $module_result.node_id ),
                   ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' ),
                   0, 5 )
                   depth=1
                   last_level=0}

André R.

Wednesday 11 July 2007 7:05:13 am

the code fragment was an example on how to read and write variables from an template from inside a template operator.

On your code example you can use hash

{def $my_hash = hash('name','my name', 'age', 89, 'sex', 'male')}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Mark Emms

Tuesday 17 July 2007 6:12:01 am

OK - thank you very much.