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.

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

eZ debug

Timing: Jan 31 2025 04:13:47
Script start
Timing: Jan 31 2025 04:13:47
Module start 'layout'
Timing: Jan 31 2025 04:13:47
Module start 'content'
Timing: Jan 31 2025 04:13:47
Module end 'content'
Timing: Jan 31 2025 04:13:47
Script end

Main resources:

Total runtime0.0126 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0045 588.3906151.2422
Module start 'layout' 0.00450.0024 739.632836.7109
Module start 'content' 0.00690.0046 776.3438102.2500
Module end 'content' 0.01150.0011 878.593841.9922
Script end 0.0126  920.5859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002016.0164140.0001
Check MTime0.00108.1226140.0001
Mysql Total
Database connection0.00054.187010.0005
Mysqli_queries0.002217.371730.0007
Looping result0.00000.158810.0000
Template Total0.00086.310.0008
Template load0.00065.026310.0006
Template processing0.00021.253310.0002
Override
Cache load0.00043.504610.0004
General
dbfile0.00118.812580.0001
String conversion0.00000.054840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs