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

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

eZ debug

Timing: Jan 31 2025 03:27:05
Script start
Timing: Jan 31 2025 03:27:05
Module start 'layout'
Timing: Jan 31 2025 03:27:05
Module start 'content'
Timing: Jan 31 2025 03:27:05
Module end 'content'
Timing: Jan 31 2025 03:27:05
Script end

Main resources:

Total runtime0.0281 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.1563151.2109
Module start 'layout' 0.00540.0049 739.3672220.6875
Module start 'content' 0.01030.0161 960.05471,001.9297
Module end 'content' 0.02640.0016 1,961.984437.9922
Script end 0.0280  1,999.9766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002810.1102140.0002
Check MTime0.00124.1695140.0001
Mysql Total
Database connection0.00082.983910.0008
Mysqli_queries0.003111.187930.0010
Looping result0.00010.189510.0001
Template Total0.00114.110.0011
Template load0.00093.193910.0009
Template processing0.00020.838010.0002
Override
Cache load0.00062.227510.0006
General
dbfile0.00248.464080.0003
String conversion0.00000.039140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs