The Javascript popupmenu in 3.5

Author Message

Siw Helen Thorslund

Sunday 03 April 2005 3:30:27 am

I read the article about this topic ( http://www.ez.no/ez_publish/documentation/incoming/javascript_popupmenu ), but I just don't get this to work.

Any of you that could give an example of a popup topmenu?

Thanx.. :)

www.VZT.no ( http://www.VZT.no )
VZT References ( http://http://vzt.no/index.php/vzt_eng/referanser )
VZT Extensions ( http://vzt.no/index.php/vzt_eng/extensions )
www.MediaBase.no ( http://www.MediaBase.no )

Frederik Holljen

Sunday 03 April 2005 10:23:50 am

A bit more information about what you tried and what didn't work would be nice. Did you turn on javascript debug? This often gives useful clues.

Lazaro Ferreira

Sunday 03 April 2005 11:13:33 am

Hi,

We have implemented dinamic (get content on fly) popupmenus linked to ezp top and left menu respectively

Basically, you need to override ezp standard popupmenu and call it from your ezp menu template (left or top)

Follows portion of the ezp left menu template (3.4 version), see the include of the popup_menu at the bottom

<div id="leftmenu">
<div id="leftmenu-design">
...
	{let docs=treemenu( $module_result.path,
						$module_result.node_id,
						array('folder','article'),
						1,
						2)
		 depth=6}
    
	    <ul>
        {section var=menu loop=$:docs last-value}
...			
            	 <a id="childrenMenuAnchor{$menu.id}" class="{$menu.is_selected|choose( '', 'selected' )}" href={$menu.url_alias|ezurl}>{$menu.text}</a>
            {set depth=$menu.level}
        {/section}
           </li>
...
        </ul>
	<b>{include uri='design:popupmenu/popup_menu.tpl' children=$:docs anchor='childrenMenuAnchor'}</b>

{/let}
...
</div>

Follows the code of the overrided popup_menu.tpl to be included above
This sample fecth the content of the menu items dinamically, but you can put the content of the menu items hardcoded to

<script language="JavaScript" src={"javascript/lib/ezjslibdomsupport.js"|ezdesign}></script>
<script language="JavaScript" src={"javascript/lib/ezjslibmousetracker.js"|ezdesign}></script>
<script language="JavaScript" src={"javascript/popupmenu/ezpopupmenu.js"|ezdesign}></script>
{section show=$children|gt(0)}
<script language="JavaScript1.2" type="text/javascript">
var menuArray = new Array();
</script>
{section var=cm show=$children|gt(0) loop=$children}

{let  root_node=fetch( content, node, hash( node_id, $cm.id ) )
      subdocs=fetch( 'content','list',hash('parent_node_id',$cm.id,
						 'sort_by', $root_node.sort_array,
						 'class_filter_type','include',
						 'class_filter_array',array( 'article', 'folder' )))}
	
{section show=$:subdocs|count()}
<script language="JavaScript1.2" type="text/javascript">
	
		menuArray['ChildrenMenu{$cm.id}'] = new Array();
		menuArray['ChildrenMenu{$cm.id}']['depth'] = 0;
		menuArray['ChildrenMenu{$cm.id}']['headerID'] = 'menu-header';
		menuArray['ChildrenMenu{$cm.id}']['elements'] = new Array();
	
		{section var=cme show=$:subdocs|gt(0) loop=$:subdocs}
			menuArray['ChildrenMenu{$cm.id}']['elements']['menu-{$cme.node_id}'] = new Array();
			menuArray['ChildrenMenu{$cm.id}']['elements']['menu-{$cme.node_id}']['url'] = {$cme.url_alias|ezurl};
		{/section}
		aelement = document.getElementById( '{$anchor}{$cm.id}' );
		aelement.onmouseover = function(e) {literal}{ezpopmenu_showTopLevel( e, 'ChildrenMenu{/literal}{$cm.id}{literal}'); return false;}{/literal};
</script>	
<!-- Treemenu icon click popup menu -->
<div class="popupmenu" id="ChildrenMenu{$cm.id}">
	{section var=cme show=$:subdocs|count() loop=$:subdocs}
    	<a id="menu-{$cme.node_id}" href="#" onmouseover="ezpopmenu_mouseOver( 'ChildrenMenu{$cm.id}' )">{$cme.name|shorten( 50 )}</a>
	{/section}
</div>
{section-else}
<script language="JavaScript1.2" type="text/javascript">
		aelement = document.getElementById( '{$anchor}{$cm.id}' );
		aelement.onmouseover = function() {literal}{ezpopmenu_hideAll(); return false;}{/literal};
</script>	
{/section}
{/let}
{/section}
<script language="JavaScript" src={"javascript/lib/ezjslibdomsupport.js"|ezdesign}></script>
<script language="JavaScript" src={"javascript/lib/ezjslibmousetracker.js"|ezdesign}></script>
<script language="JavaScript" src={"javascript/popupmenu/ezpopupmenu.js"|ezdesign}></script>
{/section}

Above you can see js code nested with ezp template code in specific way,
you can change this to swit your needs, but the important thing is that your code needs the js libs in order to work

Lazaro
http://www.mzbusiness.com

Siw Helen Thorslund

Monday 04 April 2005 7:07:14 am

Thanx for the code, but I just can't get this to work..

Is there any other simple javascript popup menu that anyone have implemented, with some examples?

www.VZT.no ( http://www.VZT.no )
VZT References ( http://http://vzt.no/index.php/vzt_eng/referanser )
VZT Extensions ( http://vzt.no/index.php/vzt_eng/extensions )
www.MediaBase.no ( http://www.MediaBase.no )

laurent le cadet

Wednesday 06 April 2005 9:48:33 am

Hi,

I'm very interesting by this kind of menu.

Lazaro, you show us how to print a depth 0 menu.
It's ok and very usefull.

It would be nice that we can show "subsubmenu" depth 1 (2,3,...).

I can't manage to make it work by myself.

Any help ?

Laurent.

Siw Helen Thorslund

Friday 08 April 2005 4:04:13 am

I would also appreciate an example that shows a menu with "subsubmenu" depth 1 (2,3,...)

Anyone that have an example they could show about this?

www.VZT.no ( http://www.VZT.no )
VZT References ( http://http://vzt.no/index.php/vzt_eng/referanser )
VZT Extensions ( http://vzt.no/index.php/vzt_eng/extensions )
www.MediaBase.no ( http://www.MediaBase.no )

Lazaro Ferreira

Friday 08 April 2005 5:37:00 am

Hi,

Here the ideia is simply to keep popupmenu (js menu) at top level only, but at the same time link it dinamically at any ezp html submenu level, so this code should be capable of produce several top level popupmenues, each of them linked to the corresponding ezp html SUBMENU item

I think that in order to produce popup SUBMENUES , you could replace the <b>list</b> command by the <b>tree</b> command at the popupmenu.tpl code above, then put the JS code block under a nested loop (because it will deal with a two dimention array ), then replace the

ezpopmenu_showTopLevel

with

ezpopmenu_ShowSubLevel

api to show every sub-menu level

Lazaro
http://www.mzbusiness.com

laurent le cadet

Friday 08 April 2005 9:24:37 am

Hi Lazaro,

Could you show us which kind of loop ?

Thanks.

Laurent.

Luc Chase

Thursday 04 August 2005 11:54:47 am

Is there a URL showing this popup menu in action? Is it the same as the popup menu used in the admin interface?

The Web Application Service Provider

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