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.

eZ debug

Timing: Jan 20 2025 06:04:20
Script start
Timing: Jan 20 2025 06:04:20
Module start 'content'
Timing: Jan 20 2025 06:04:20
Module end 'content'
Timing: Jan 20 2025 06:04:21
Script end

Main resources:

Total runtime0.9248 sec
Peak memory usage4,096.0000 KB
Database Queries209

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 589.2109180.7969
Module start 'content' 0.00570.7595 770.0078617.7422
Module end 'content' 0.76520.1595 1,387.7500345.0234
Script end 0.9247  1,732.7734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.4282210.0002
Check MTime0.00150.1586210.0001
Mysql Total
Database connection0.00070.080910.0007
Mysqli_queries0.819188.57172090.0039
Looping result0.00250.26952070.0000
Template Total0.896596.920.4483
Template load0.00210.228720.0011
Template processing0.894496.717120.4472
Template load and register function0.00010.009110.0001
states
state_id_array0.00080.082710.0008
state_identifier_array0.00090.098520.0005
Override
Cache load0.00190.2008600.0000
Sytem overhead
Fetch class attribute can translate value0.00150.162230.0005
Fetch class attribute name0.00250.2708100.0003
XML
Image XML parsing0.00140.147130.0005
class_abstraction
Instantiating content class attribute0.00000.0038160.0000
General
dbfile0.00640.6927340.0002
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs