Forums / Developer / SIte selector (children of root node)

SIte selector (children of root node)

Author Message

David Jones

Wednesday 27 September 2006 7:25:41 am

I am running a number of site from one ezp admin system.

I have a collection of folders below the root node (id 2) which contain indervidual sites.

I can access them via /site1/ or /site 2/ etc

I wont to create a site selector drop down. to go at the top of each page.

How do I select and display the children of the root node.

I have tried the following with no joy.,

{
set menu_items=fetch( 'content', 'list', hash( 'parent_node_id', 2, sort_by, array( priority, true ),) ) 

      }         
<ul>
 {section loop=$menu_items}
 <li><a href={$item.url_alias|ezurl}>{attribute_view_gui attribute=$item.object.data_map.short_name}</a></li>
{/section}            
</ul>

Please help.

Claudia Kosny

Wednesday 27 September 2006 7:53:43 am

Hello David

You might want to use def $menu_items... instead of set, but this depends on whether you have def'ed the variable menu_items somewhere before in your template. Anyway you should use a $ in front of the variable. There is also a comma to much and the parentheses for the true() are missing (although I am not sure whether one needs them).

Just use foreach to go through the loop, that makes it easier to understand. If the attribute short_name of your items is a text lien you just can use the content of this attribute, no need to use the attribute_view_gui function. If you need it, just replace the inner html of the a href with your code again.

{def $menu_items = fetch('content', 'list', hash('parent_node_id', 2,
                                                                  'sort_by', array('priority', true())))}
{foreach $menu_items as $item}
<li>
 <a href={$item.url_alias|ezurl}>{$item.object.data_map.short_name.content|wash()} </a>
</li>
{/foreach}

(the code is not tested and will most likely contain some typos)

I am pretty sure that you got some messages in the debug output, next time please have alook there first and post the error messages if necessary.

Greetings from Luxembourg

Claudia

David Jones

Thursday 28 September 2006 1:34:25 am

That works brilliantly, thanks.

What I need to do is put those links into a drop down list. And so, when I hit the submit button it redirects off to the correct page.

Is this possible with EZP?

Nabil Alimi

Thursday 28 September 2006 12:55:32 pm

Hi David,

In this case, that's not "really" EzPublish that will solve that but Javascript.

There's a lot of way to handle this.
Here's one.
You can set the <i>action</i> value of your form "on the fly".
Here is the scenario.
Have an "onchange" event on your dropdown list like this :

<select [...] onchange="this.form.action= this.optionsList[selectedIndex]">

As far as I remember, there is no "value" field in a <select> tag.That's why the "optionList".
But I do not remember the exact name of the array that contains the options.

Like this, when you will submit the form you'll get to the url selected in your dropdownlist.

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

David Jones

Friday 29 September 2006 3:37:02 am

Thanks but I specifcally didn't want to use JavaScript

I found a solution via here

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

if any body is interested