Extracting the current navigation position within a loop

Author Message

steve walker

Friday 12 March 2004 3:02:20 am

Hi there,

I have a loop used to generate the main naviagtion, and I am building the tabbed effect ala EZ.no - its almost there (hurray!) and from previous post found lots of good info from http://ez.no/ez_publish/documentation/reference/template_functions/program_flow/section

However, my final issue is adding a bit of script to the loop that says:

"if this link is the current down/acitve link, print this" so that I can add a id="down link colour" within the array thats generated....

So the static html looks like this (from the tutyorial i'm using):

<li><a href="#">Home</a></li>
<li id="current"><a href="#">News</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>

The code I'm using to loop is:

{let content=$pagedesign.data_map.image.content}
<div id="logo">
<a href={"/"|ezurl}><img src={$content[logo].full_path|ezroot} /></a>
</div>
{/let}

and I just need to build in the code that adds 'id="current"' for the current page thats being displayed.

Any ideas or pointers to information that answers this would be greatly appreciated.

Thanks, Steve.

http://www.oneworldmarket.co.uk

Paul Forsyth

Friday 12 March 2004 3:16:57 am

Have you read the new treemenu docs for 3.3?

http://ez.no/ez_publish/documentation/reference/template_operators/miscellaneous/treemenu

Lots of good stuff to support what you are doing.

paul

steve walker

Friday 12 March 2004 9:13:15 am

Paul,

Thanks for your reply.

I've taken a look at the page, its helpful and demonstrates the code

<li class="level_{$menu.item.level}">

but doesnt give info on extracting information within the the navigation level... Sorry to be a pain, but do you have any ideas how to code:

"{if this link is the active/clicked link print id="current"}" so I can apply a different css style to the current area a person has naviagted to?... i.e. how the 'community' tab looks on the top of this page?

Thanks for the help.

Steve.

http://www.oneworldmarket.co.uk

Paul Forsyth

Friday 12 March 2004 1:42:46 pm

Well, for standard tests for items you need need to match a known node id to the current node id, eg:

{let content=$pagedesign.data_map.image.content
     news_node_id=24}
<div id="logo">
{section show=eq($node.node_id, $news_node_id)}
<a href={"/"|ezurl}>Hello! Im selected</a>
{section-else}
<a href={"/"|ezurl}><img src={$content[logo].full_path|ezroot} /></a>
{/section}
</div>
{/let}

You need to get the current node somehow though.

paul

steve walker

Monday 15 March 2004 5:01:21 am

Paul,

Thanks! I'm almost there!! Its almost working!

The code I have for the navigation is:

{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))}

{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 show=eq($:item.node_id,$used_node)}
<li id="current"><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}>{$:item.name}</a></li>
{section-else}
<li><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}>{$:item.name}</a></li>
{/section}

{/section}
{/let}
{/let}

The remaining problem is with: {section show=eq($:item.node_id,$used_node)}.
It works fime providing you are clicking on the top level navigatin, but as soon as you go into a sub-folder of the navigation, the used_node id takes on the sub-nav id and it stops this section show working as it ought.

So, my last bit of the jigsaw is - how do i get the parent navigation, i.e. the level below top_cat var - and take just those node values...

Is there a default template var I can use??

Many thanks, Steve

http://www.oneworldmarket.co.uk

steve walker

Monday 15 March 2004 7:28:45 am

Hoping to have answered my own que from:

http://ez.no/community/forum/setup_design/finding_the_top_but_one_node_id

Steve

http://www.oneworldmarket.co.uk

steve walker

Monday 15 March 2004 8:29:36 am

Hi there,

As in my mail before last am trying to tweak this code :(((((

{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))}

{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))))}
used node = {$DesignKeys:used.node}

{section show=eq($:item.node_id,$used_node)}
<li id="current"><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}>{$:item.name}</a></li>
{section-else}
<li><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}>{$:item.name}</a></li>
{/section}

{/section}
{/let}
{/let}

Just so that instead of {section show=eq($:item.node_id,$used_node)}
I have something like {section show=eq($:item.node_id,$PARENT-NODE)}

Any help would be appreciated, this is drving me crazy..... 3 days down the toilet trying to suss this code :(

Thanks, Steve.

http://www.oneworldmarket.co.uk

Paul Forsyth

Monday 15 March 2004 9:13:24 am

Are you trying to show several levels? Your current fetch command will only return one level. If this is what you want i really would consider looking at the treemenu operator. It does this.

Paul

steve walker

Monday 15 March 2004 9:40:37 am

Paul,

Thankyou for the response.

Yes, I have other levels, but this is further down the code, the subnav....
I had looked at treemenu operator, but as far as I'm aware I cannot create a specific 'class' to apply on the the currently selected node... this is my issue.

Am I wrong here?

Steve.

http://www.oneworldmarket.co.uk

Paul Forsyth

Monday 15 March 2004 10:01:14 am

If you are referring to a css class you can with the treemenu operator. There are some good examples in that piece of documentation, which you can use.

Copy and paste an example and see if it works. If there something you don't understand about the operator, post back here.

paul

steve walker

Monday 15 March 2004 10:23:07 am

Paul,

Fantastic, it seems i'm there :)))))) I have added this to the code to propogate the class ID info to the current tab selected, not sure its very good code writing:

{section loop=fetch(content,list,hash(parent_node_id,$top_cat, class_filter_type, "include", class_filter_array, array(),sort_by,array(array(priority))))}
<li
{section show=eq($:item.node_id,$used_node)}
id="current"
{section-else}
{section show=$node_obj.path_array|contains($:item.node_id)}
id="current"
{/section}
{/section}
> <a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}>{$:item.name}</a></li>

... but its godamn working and my blood pressure has just dropped dramatically.

Thanks for the help.

Steve.

http://www.oneworldmarket.co.uk

Paul Forsyth

Monday 15 March 2004 10:26:55 am

Hey, if it works, it works :)

ashok ashok

Tuesday 20 April 2004 6:06:27 am

hello friends,
i am new to ezpublish. I just installed the ezpublish on my local pc. I am trying to integrate the layout and also i want to change little bit according to our needs. But i have not understood the following code
1)

$pagedesign.data_map.image.content :

what exactlly this code does?
2)

{let folder_list=fetch( content, list, hash( parent_node_id, 2, sort_by, array( array( priority ) ) ) )} :

Here i know that this code is loop fetching value from database but how it does . and from which table it fetching the data.
3)

$Folder:item.node_id :

what exactly this code does?
4)

$News:item.node_id/({$News:item.object.published|l10n( shortdate )}) :

what exactly these code does?
5)

action={"/content/search/"|ezurl} 

: What is action page here. Does the value coming from database.
6)How do i add javascript validation to form.
Please explain me these qtns. Then afterwards may be i can easily interate my design on ezpublish.
Also I want to know that how will i enchance this software accroding to my needs. What should be the procedure. For example(In caontact us page there are three fields Subject , emailid, message.) now how will i add one more form element may be it is checkbox, radiobutton, listbox anything.
I need to integrate layout and enchace this very fast . It is very very urgent . Please explain the above points so that i can build the ezpublish easy and fast.
Thanks to you all
Bye
Ashok NAidu

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