Share » Forums » Developer » External links in menu

External links in menu

External links in menu

Wednesday 16 July 2003 12:15:08 am - 4 replies

Author Message

Valentin Svelland

Friday 25 July 2003 12:56:43 am

Still haven't figured this one out.. :(

Alex Jones

Friday 25 July 2003 6:43:26 am

Valentin, I'm running into the same issue myself. I tried using a "link" but I cannot find a way to have it poitn directly at the URL in my navigation. Instead, it always links to the page (node) about the external site.

It doesn't make much sense.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Petrus Viitanen

Monday 25 April 2005 4:44:43 am

Hi both of you,

I'm struggling with the same problem here, so if you have found a solution please share it with us. I would like to create links that open directly from the menu.

-Peetuli

Yngve Bergheim

Tuesday 03 January 2006 2:29:14 am

I also needed external links in the left menu. So I wrote an modification of templates/menu/flat_left.tpl

Now you just can include an external link with the build in eZ link class. Never figured out what the link class was good for anyway when you have other ways to include links in articles.

Make sure you have included link class in menu.ini.append.php [MenuContentSettings].

If you want you can hide link class in folder.tpl.

The complete file templates/menu/flat_left.tpl:

{def $menu_level_one_less=0}
{def $hideSubMenu=false()}
{* We can't manipulate $menu.url_alias, so we make an local variable *}
{def $this_url_alias=''}

{let docs=treemenu( $module_result.path,
                    is_set( $module_result.node_id )|choose( 2, $module_result.node_id ),
                    ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' ),
                    0, 10 )
                    depth=1
                    last_level=1}
                    
	<h3 class="hide">{"Left menu"|i18n("design/base")}</h3>  
	<ul>

	{section var=menu loop=$:docs last-value}

		{set last_level=$menu.last|is_array|choose( $menu.level, $menu.last.level )}

		{* Bug fix: folder as sub items beneath an article make the menu break *} 
		{* This fix make all menu items that have an illegal menu.level jump (more than 1) *}
		{* not to be displayed *}
        {set $menu_level_one_less=sub( $menu.level, 1)}
        {if gt( $menu_level_one_less, $last_level ) }
        	{set $hideSubMenu=true()}
        {/if}
        {if eq($hideSubMenu, true() )}
        	{if eq($menu.level, 0)}
        		{set $hideSubMenu=false()}
        	{/if}
        {/if}
		
        {* Display external urls in a link class *}
        {* NB. Make sure you have included link class in: *} 
        {* menu.ini.append.php [MenuContentSettings] *}
        {def $my_node=fetch( 'content', 'node', hash( 'node_id', $menu.id ) )}        
		{set $this_url_alias=$menu.url_alias}
		{if ne($my_node.object.data_map.location.content, '')}
			{set $this_url_alias = $my_node.object.data_map.location.content}
		{/if}  	
        
        {* Don't show some menu nodes *}
        {if and( eq($hideSubMenu, false() ), ne($menu.id, 1267), ne($menu.id, 1330) )}
     	  	{section show=and( $last_level|eq( $menu.level ), $menu.number|gt( 1 ) )}
	            </li>
	        {section-else}
	            {section show=and( $last_level|gt( $menu.level ), $menu.number|gt( 1 ) )}
	                </li>
	                    {"</ul>
	                </li>"|repeat(sub( $last_level, $menu.level ))}
	            {/section}
	        {/section}
	
	        {section show=and( $last_level|lt( $menu.level ), $menu.number|gt( 1 ) )}
	            <ul>
	                <li {$menu.is_selected|choose( '', 'class="on"' )}>
	        {section-else}
	            <li {$menu.is_selected|choose( '', 'class="on"' )}>
	        {/section}
	
	        <a {$menu.is_selected|choose( '', 'class="on"' )} href={$this_url_alias|ezurl}>{$menu.text}</a>
			
	        {/if}
	        {set depth=$menu.level}
	    {/section}
	       </li>
	
	    {section show=sub( $depth, 0 )|gt( 0 ) loop=sub( $depth, 0 )}
	        </ul>
	    </li>
		{/section}
   
    </ul>

{/let}
{undef $this_url_alias}
{undef $menu_level_one_less}
{undef $hideSubMenu}

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu