ezwebin Template Overrides

Author Message

Betsy Gamrat

Friday 22 December 2006 10:50:01 am

I modified menu/flat_top.tpl through the admin interface, but the override template was not used in the display.

I'm not sure it if is a bug, or if this template is not intended to be modified.

As a side note, this is the modification:

I created a new class called <b>Navigation</b>, which consists of two attributes, a <i>name</i> and an <i>object relation list</i>. Next, I created the content and related it to the items I wanted in the navigation. Finally, I modified the template to use the node, and added an <b>Edit</b> link (using the eZ logo image). This allows the navigation of ezwebin to be managed by through the website interface in addition to the admin interface. It also allows content to be 'hidden' by preventing its display in the navigation.

$top_menu_root_node is the node which contains the object relation list. I just hard-coded the node id (145) in to the template, a more graceful approach is certainly possible.

<b>menu/flat_top.tpl</b>

 <div class="topmenu-design">
    <!-- Top menu content: START -->
        <ul>
        {def $root_node=fetch( 'content', 'node', hash( 'node_id', $indexpage ) )
        $top_menu_root_node=fetch( 'content', 'node', hash( 'node_id', 145 ) )
        $top_menu_items=fetch( 'content', 'related_objects',hash( 'object_id',$top_menu_root_node.contentobject_id,'all_relations', true()) )
        $top_menu_items_count = $top_menu_items|count()
        $item_class = array() $item = array()
        $current_node_in_path = cond(and($current_node_id, gt($module_result.path|count, $pagerootdepth)), $module_result.path[$pagerootdepth].node_id, 0
)}
    {set $pagerootdepth = $root_node.depth}
        {if $top_menu_root_node.can_edit}
        <li class="edit-nav"><a href={concat('/content/edit/',$top_menu_root_node.contentobject_id)|ezurl} title="Edit navigation items"><img src={'images/
ez_toolbar.png'|ezdesign(no)}></a></li>
    {/if}

    {if $top_menu_items_count}
       {foreach $top_menu_items as $key => $item_obj}
            {set $item = $item_obj.main_node}
            {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 fal
se;"{/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' )}{conc
at("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>
                {/if}
        {/foreach}
    {/if}
    {undef $root_node $top_menu_items $item_class $top_menu_items_count $current_node_in_path $top_menu_root_node}
    </ul>
    <!-- Top menu content: END -->
</div>

Kristof Coomans

Friday 22 December 2006 10:40:30 pm

Hi Betsy

Can you tell us where the override template is located now? Is it in a design under the main design/ dir?

There's a problem with the order the design resources are used, see bug http://issues.ez.no/9595 , it could be related to your problem. First of all the order of the design resources differs between ezimage/ezdesign template operators and template fetching. But there's more: extension designs are always used before designs in the main design/ dir. Because the ezwebin design is in an extension, this could be the issue here.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Betsy Gamrat

Saturday 23 December 2006 8:27:22 pm

Kristof,

I tried to use the admin console to create the override template, and it looked like it created it in the ezwebin/design/ezwebin/override/templates directory, but the changes didn't take effect.

My solution was just to modify the ezwebin/design/ezwebin/design/menu/flat_top.tpl file, which worked well.

Betsy

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