Retrieve Database by Priorities!

Author Message

Guilherme Longo

Friday 31 August 2007 2:32:55 am

I'm trying do something like this:

In my template have 2 topbars menu, one directly created in my template and another one defined by Nodes in the TOP LEVEL CONTENT.

When I create Nodes in my TOP LEVEL CONTENT, automatically is created items in my menubar but i want create some content in TOP LEVEL CONTENT and your respective buttons appears in another menubar.

Ok, just created another <li> directly in my template and linked the respective content .

But now i want hidden my button from the first menubar, that one managed by web interface (TOP LEVEL CONTENT)

Ok, i put priorities for organize and now i'm looking for how can i retrieve that priorities number from database for create one rule in PHP for say: if x=0, hidden ;O))))

Someone can help-me?

Thank very much!

Guilherme Longo

Monday 03 September 2007 2:35:39 am

hello again!

nobody understood what i am meaning or it is something impossible to do?

thank

André R.

Monday 03 September 2007 3:42:16 am

Your first option actually, so try to rephrase your whole question.

An example of how to fetch multiple levels off menus and sort them using sorting form database can be found here:
http://zev.ez.no/svn/extensions/ezwebin/trunk/packages/ezwebin_extension/ezextension/ezwebin/design/ezwebin/templates/menu/flat_left.tpl

the part you are looking for is probably this: $item.sort_array

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Guilherme Longo

Monday 03 September 2007 5:14:59 am

ok Andre, i'll try make a better explanation.
so, i'm using one template X
This template has 2 menu bars.

the first menu, is managed by web interface. When I include nodes in the top level tree of content, for exemple: Folder CUSTOMERS, the button CUSTOMERS appears in this menu.

the second menu, does'nt work like the first. For include buttons in the second menu, I need put code like that:

<li><a href={"/user/logout"|ezurl} title="{$pagedesign.data_map.logout_label.data_text|wash}">{$pagedesign.data_map.logout_label.data_text|wash} ( {$current_user.contentobject.name|wash} )</a></li>

directly in my template.

I want hide 1 button of my first menu, but i dont want put hidden directly by web interface, becouse all content of my button will be hidden too. I just want that the "button" does'nt appears in my web. HOW TO DO IT?

I think in sort the node of tree content by priority and using php, retrieve these priorities and make some code to hide the button that i want that does'nt appear.

IF I DID'NT EXPLANED RIGHT, PLEASE TELL ME WHERE, BECAUSE A DID'NT FIND HOW TO DO IT.

thank

André R.

Monday 03 September 2007 7:43:35 am

The most clean way to hide some of the links from the menu, is to use a class that does not show up in the menu.
You can use the advanced -> swap nodes in the javascript menu in the admin interface to swap the node out with another one.

Alternatively you can filter it out in you menu code with a simple:

{foreach $menu_nodes as $item}
{* filter out node id 355 *}
{if $item.node_id|ne( 355 )}
<li>...menu code...</li>
{/if}
{/foreach}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Guilherme Longo

Monday 10 September 2007 4:01:40 am

André, I've already adapted this code in my flat_top.tpl template.

look this:

{if $top_menu_items_count}
{foreach $top_menu_items as $key => $item}
{set $item_class = cond($current_node_in_path|eq($item.node_id), array("selected"), array())}
{if $key|eq(0)}
{set $item_class = $item_class|append("firstli")}
{/if}
{if $top_menu_items_count|eq( $key|inc )}
{set $item_class = $item_class|append("lastli")}
{/if}
{if $item.node_id|eq( $current_node_id )}
{set $item_class = $item_class|append("current")}
{/if}

{if eq( $item.class_identifier, 'link')}
<li id="node_id_{$item.node_id}"{if $item_class} class="{$item_class|implode(" ")}"{/if}><div><a href={if eq( $ui_context, 'browse' )}{concat("content/browse/", $item.node_id)|ezurl}{else}{$item.data_map.location.content|ezurl}{/if} target="_blank"{if eq( $ui_context, 'edit' )} onclick="return false;"{/if}><span>{$item.name|wash()}</span></a></div></li>
{else}

<b>{foreach $menu_nodes as $item}
{if $item.node_id|ne(170)}
<li id="node_id_{$item.node_id}"{if $item_class} class="{$item_class|implode(" ")}"{/if}><div><a href={if eq( $ui_context, 'browse' )}{concat("content/browse/", $item.node_id)|ezurl}{else}{$item.url_alias|ezurl}{/if}{if eq( $ui_context, 'edit' )} onclick="return false;"{/if}><span>{$item.name|wash()}</span></a></div></li></b>
<b>{/if}</b>
<b>{/foreach}</b>

{/if}
{/foreach}
{/if}

but, when i put this code, all buttons disappear from my menu bar.

I understood you wrong or is this implementation wrong?

Guilherme Longo

Monday 10 September 2007 5:47:35 am

Sorry André. Again you was right.

I was putting the code in one wrong part section.

I did like it:

{if $top_menu_items_count}
{foreach $top_menu_items as $key => $item}
<b>{if $item.node_id|ne(170)}</b>
{set $item_class = cond($current_node_in_path|eq($item.node_id), array("selected"), array())}
{if $key|eq(0)}
{set $item_class = $item_class|append("firstli")}
{/if}
{if $top_menu_items_count|eq( $key|inc )}
{set $item_class = $item_class|append("lastli")}
{/if}
{if $item.node_id|eq( $current_node_id )}
{set $item_class = $item_class|append("current")}
{/if}

{if eq( $item.class_identifier, 'link')}
<li id="node_id_{$item.node_id}"{if $item_class} class="{$item_class|implode(" ")}"{/if}><div><a href={if eq( $ui_context, 'browse' )}{concat("content/browse/", $item.node_id)|ezurl}{else}{$item.data_map.location.content|ezurl}{/if} target="_blank"{if eq( $ui_context, 'edit' )} onclick="return false;"{/if}><span>{$item.name|wash()}</span></a></div></li>
{else}
<li id="node_id_{$item.node_id}"{if $item_class} class="{$item_class|implode(" ")}"{/if}><div><a href={if eq( $ui_context, 'browse' )}{concat("content/browse/", $item.node_id)|ezurl}{else}{$item.url_alias|ezurl}{/if}{if eq( $ui_context, 'edit' )} onclick="return false;"{/if}><span>{$item.name|wash()}</span></a></div></li>
<b>{/if}</b>
{/if}
{/foreach}
{/if}

and is working perfect.
Thank you so much again!

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 19 2025 00:16:15
Script start
Timing: Jan 19 2025 00:16:15
Module start 'layout'
Timing: Jan 19 2025 00:16:15
Module start 'content'
Timing: Jan 19 2025 00:16:17
Module end 'content'
Timing: Jan 19 2025 00:16:17
Script end

Main resources:

Total runtime1.4919 sec
Peak memory usage4,096.0000 KB
Database Queries69

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 587.9141152.6250
Module start 'layout' 0.00480.0038 740.539139.4609
Module start 'content' 0.00861.4816 780.0000608.0781
Module end 'content' 1.49020.0017 1,388.078120.7813
Script end 1.4918  1,408.8594 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2131160.0002
Check MTime0.00120.0815160.0001
Mysql Total
Database connection0.00050.036110.0005
Mysqli_queries1.411794.6258690.0205
Looping result0.00060.0427670.0000
Template Total1.457697.720.7288
Template load0.00190.128720.0010
Template processing1.455797.573120.7278
Template load and register function0.00030.016810.0003
states
state_id_array0.00170.111110.0017
state_identifier_array0.00190.129020.0010
Override
Cache load0.00180.1202960.0000
Sytem overhead
Fetch class attribute can translate value0.00050.030420.0002
Fetch class attribute name0.00130.088980.0002
XML
Image XML parsing0.00070.047920.0004
class_abstraction
Instantiating content class attribute0.00000.001490.0000
General
dbfile0.00080.0510170.0000
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 33
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs