Generating a "title" attribute for menu entries

Author Message

Michaël D.

Wednesday 27 August 2008 4:51:52 am

Hello,

I'm trying to have "tooltips" displayed when one is hovering the main menu entries (to give a short description of it), but I can't figure out how to retrieve the information in the menu template. I use the template below, which is a modified topdrop menu. I want the description to go in <a title="description">Menu entry</a>

{def 
$goleft=ezini( 'TopDrop', 'goleft', 'design.ini')
$item_class = array()
$current_node_in_path = first_set($module_result.path[1].node_id, 0 )
}

{let top_cat=2 used_node=false()}
{set used_node=2}
	
<div class="menu"><ul> {def $base=fetch( 'content', 'node', hash( 'node_id', 2 ) )} 

{* FIRST LEVEL *}

{def $i=0}

{section loop=fetch(content,list,hash(parent_node_id,$top_cat, class_filter_type, "include", class_filter_array, array(1, 16, 17, 19, 20, 23, 38, 39),sort_by,$base.sort_array))}
	{let child_check=fetch(content,list,hash(parent_node_id,$:item.node_id, class_filter_type, "include", class_filter_array, array(1, 16, 17, 19, 20, 23, 38, 39),sort_by,$base.sort_array))}
	{set $i=inc( $i )}
	{set $item_class = cond($current_node_in_path|eq($item.node_id), array("selected"), array())}

	<li class="{$item_class|implode(" ")}"><a class="{concat('menu_',$i)}" title="{$:item.name}" href={$:item.url_alias|ezurl}>{$:item.name}

{section show=$child_check|count|gt(0)}
	{* SECOND LEVEL *}
...from here it's default topdrop...

For the moment the code gives me obviously the same content for the entry and the description. How to do something like $node.data_map.description in this context? Thanks!

Ivo Lukac

Wednesday 27 August 2008 5:44:44 am

Hello

You can do ti like this if your description attribute is simple text:

<a class="{concat('menu_',$i)}" title="{$:item.data_map.description.content}" href={$:item.url_alias|ezurl}>
 

If your description attribute is not simple text (for example online editor text) then you need to strip_tags. About strip_tags you can find out more on this forum.

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Michaël D.

Thursday 28 August 2008 12:06:59 am

It's indeed simple text, and your solution works perfectly :-)
Thanks a lot for your help !

André R.

Thursday 28 August 2008 12:31:02 am

Remember to use the wash operator in case the content includes " for instance.

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

Ivo Lukac

Thursday 28 August 2008 1:06:45 am

Yes, of course:

<a class="{concat('menu_',$i)}" title="{$:item.data_map.description.content|wash}" href={$:item.url_alias|ezurl}>
 

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

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 18 2025 14:54:30
Script start
Timing: Jan 18 2025 14:54:30
Module start 'layout'
Timing: Jan 18 2025 14:54:30
Module start 'content'
Timing: Jan 18 2025 14:54:31
Module end 'content'
Timing: Jan 18 2025 14:54:31
Script end

Main resources:

Total runtime1.0634 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0080 588.1641152.6563
Module start 'layout' 0.00800.0026 740.820339.5078
Module start 'content' 0.01071.0515 780.3281606.3594
Module end 'content' 1.06210.0013 1,386.687516.1094
Script end 1.0634  1,402.7969 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.3441160.0002
Check MTime0.00120.1173160.0001
Mysql Total
Database connection0.00100.092810.0010
Mysqli_queries1.004094.4086650.0154
Looping result0.00070.0667630.0000
Template Total1.026896.620.5134
Template load0.00220.207120.0011
Template processing1.024696.348720.5123
Template load and register function0.00010.010910.0001
states
state_id_array0.00110.100210.0011
state_identifier_array0.00120.108820.0006
Override
Cache load0.00190.1762230.0001
Sytem overhead
Fetch class attribute can translate value0.00070.066230.0002
Fetch class attribute name0.00110.106470.0002
XML
Image XML parsing0.00130.117930.0004
class_abstraction
Instantiating content class attribute0.00000.001880.0000
General
dbfile0.00300.2782240.0001
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs