Forums / Setup & design / removing primary/first level menu redirects out of a treemenu

removing primary/first level menu redirects out of a treemenu

Author Message

steve walker

Thursday 22 April 2004 9:57:56 am

Hi there,

Wondered if anyone could give me a pointer with this little conundrum... I have a treemenu which is displayed using (the documented here) code of:

<div class="treenav">

<ul>
{* Set your top category here *}
{let top_cat=2
used_node=false()}

{* See if we have already a node id otherwise use the top category as current node *}
{section show=is_set($DesignKeys:used.node)}
{set used_node=$DesignKeys:used.node}
{section-else}
{set used_node=$top_cat}
{/section}

{* Get a proper node object *}
{let node_obj=fetch(content,node,hash(node_id,$used_node))}

{* FIRST LEVEL *}
{section loop=fetch(content,list,hash(parent_node_id,$top_cat, class_filter_type, "include", class_filter_array, array(1),sort_by,array(array(priority))))}
{section-exclude match=$:item.node_id|eq(173)}
<li id="firstlevel"><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}>{$:item.name}</a></li>

{* SECOND LEVEL *}
{section show=$node_obj.path_array|contains($:item.node_id) loop=fetch(content,list,hash(parent_node_id,$:item.node_id, class_filter_type, "include", class_filter_array, array(1),sort_by,array(array(priority))))}
<li id="secondlevel">> <a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}>{$:item.name}</a></li>

{/section}
{/section}</ul>
{/let}
{/let}
</div>

What I want is for the menu to work exactly as it is, but I dont want the main navigation levels to send you to a page, just expand the menu - so it ends up working like you are expanding treelinks, and then picking one of the subnav (second level) elements.

Basically we dont want to make section index pages!

Is my explanation clear??? Any pointers would be top!

Thanks, Steve.

http://www.oneworldmarket.co.uk

Alex Jones

Saturday 24 April 2004 8:05:21 am

This should be easy enough to do. Are you using JavaScript to expand the menus? If so, just modify the code for the First Level to display

href="#" onmousover=YOUR MENU CODE"

instead of

href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}

Leave the Second Level Code the same. One note, the best way to do it would be to leave the <i>href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}</i> and add <i>return false;</i> to the end of the JavaScript placed in the mouseover.

href={concat("/content/view/full/",$:item.node_id,"/")|ezurl} onmouseover="YOUR MENU CODE;return false;"

While the vast majority of users will only see the menu, this ensures that your site is still accessible to anyone who has disabled JS in their browsers, including search engines. But it does mean that you will have index pages - they will remain unseen for most people.

Does this help?

Alex

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

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

steve walker

Tuesday 03 August 2004 2:16:21 am

Hi!

It seems I'm back on this problem again... didnt manage to solve it last time, but found a work around - this time it seems I have to solve it :(

I'm suprised noone else has come across this - having a menu that expands to show the available sub-options without sending you to the clicked on page are common - but I guess normally use javascript.

To answer Alex's question, I'm not using javascript.

The problem is that the menu expands dependent on the nodeid of the page, but if you remove the link in the 1st level of the menu the nodeid doesnt change and so the menu doesnt expand.

So its a coding catch22.

Has anyone had to deal with a similar situation... to explain what I'm trying to do. I have a client who has 350 or so product catagories. They want a tree menu that expands, or some other form of sensible navigation. So you might choose:

Cheese >> Blue Cheeses >> Stilton

The problem is I dont want to be redirected to the index pages of 'Cheese' and 'Blue Cheese' as I expand the menu to get to 'Stilton' - its only when I click on 'Stilton' should there be any form of navigational direct.

Any thoughts or work arounds for this, especially ones that dont include java as they want the site to be as search engine friendly as possible.

Thanks, Steve.

http://www.oneworldmarket.co.uk

Kevin Myles

Tuesday 03 August 2004 8:02:52 am

Nevermind :>

Alex Jones

Tuesday 03 August 2004 9:25:19 am

Steve, one solution (less than ideal), would be to add a checkbox to the class used for your categories to toggle whether or not a link should be provided. You could then check the value of the checkbox in your code to decide whether or not you provide the link. So, in your case if Cheese and Blue Cheese were not checked, but Stilton is, your code would display the link for the Stilton page.

If there are a set number of levels, you could try detecting the current depth of the item being displayed in the menu and decide that any menu item greater than X deep would display the link. But that would require a rigid category structure which may not be realistic.

One thought in general, using JavaScript in this case shouldn't make the site any less friendly to search engines as they will merely ignore the JavaScript command to stop the load and visit the page, which conveniently will have a bunch of your keywords on it. In ranking the pages though, Google and its competitors are unlikely to offer the user these intermediary pages, as other pages on your site are likely to have the same keywords plus additional content. On our corporate site we make extensive use of menus which have links to category pages much like your own and haven't had any issues with page ranking.

Alex
bald_technologist on the IRC channel: #eZpublish
http://www.agrussell.com :: http://www.cuttingedge.com

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

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

steve walker

Tuesday 03 August 2004 12:39:36 pm

Alex,

Just a thought on how this could work, though its beyond my coding level...

The issue with current nav is that the node of the currently loaded page creates the point in which the treemenu builds itself from.

Is there a way of storing the clicked on (level1) links nodeid without navigating to its page - and when the page reloads using this stored variable to build the treenav rather than the current page nodeid.

This could be non-java script solution...?

Steve.

http://www.oneworldmarket.co.uk