Forums / Developer / Another problem in ez 3.4.1

Another problem in ez 3.4.1

Author Message

Jack Rackham

Saturday 14 August 2004 1:50:26 am

The following code works for 3.3 but not for 3.4.1 can someone help?
<h3>{""|i18n("design/news/layout")}</h3>

<h3>{""|i18n("design/news/layout")}</h3>


{let category_list=fetch( content, 'list', hash(parent_node_id,$node.parent_node_id,
'class_filter_type', 'include',
'class_filter_array', array( 31 )))}

<div id="categorylist">
<ul>
{section var=category loop=$category_list sequence=array(bglight,bgdark)}
<li class="{$category.sequence}">

<a href={$category.item.url_alias|ezurl}>{$category.item.name|wash}</a>
</li>
{/section}
</ul>
</div>{/let}


<h3>{""|i18n("design/news/layout")}</h3>

{let related_objects=$node.object.related_contentobject_array}
{section show=$related_objects}

<div class="relatedarticles">
<h2>{"Relaterte artikler"|i18n("design/magasinet/layout")}</h2>
<ul>
{section name=ContentObject loop=$related_objects show=$related_objects}
<li><a href={$ContentObject:item.main_node.url_alias|ezurl}>{$ContentObject:item.name}</a></li>
{/section}
</ul>
</div>
{/section}
{/let}

Ole Morten Halvorsen

Monday 16 August 2004 7:39:06 am

Which part of the code is not working? The first thing I would check is if the fetch return anything. This is done with the attribute operator. After your {let category_list} insert this:

{$category_list|attribute(show)}

Also, turn on debugging and check the output for any template errors.

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Mark Marsiglio

Monday 16 August 2004 7:49:12 am

If you are using this in a pagelayout.tpl instead of a full or line override template, the $node variable will not work in 3.4.

You will need to replace this with a $DesignKeys or $module_result variable instead. These can be found in the documentation.

The alternative is to reorganize your template structure to move the code into a content template rather than a pagelayout template.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

Jack Rackham

Monday 16 August 2004 9:11:53 am

Tanks for the tip $DesignKeys:used.parent_node worked. I remember that $DesignKeys did not work in the same template in 3.3. This was because $DesignKeys was not updated the same way as $node and $module_result or something like that! EZ must have changed this in 3.4.

But how do I get the related objects part of the code to work? Yes It's a pagelayout.tpl.
In 3.3 I solved this problem with not caching this part of the code but in 3.4 I don't have this alternative.

Ole Morten Halvorsen

Tuesday 17 August 2004 1:20:20 am

Jonny,

You can fetch the current node in the pagelayout which will let you access the related objects:

{let curr_node=fetch( content, node, hash( node_id, $module_result.node_id ) )}

<b>Note</b>: this fetch will not return a node on pages which does not have a node, such as /content/search, /user/login and so on.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Jack Rackham

Tuesday 17 August 2004 11:22:04 pm

So my code will be something like this?

{let curr_node=fetch( content, node, hash( node_id, $module_result.node_id ) )}
{section show=$related_objects}

<div class="relatedarticles">
<h2>{"Relaterte artikler"|i18n("design/magasinet/layout")}</h2>
<ul>
{section name=ContentObject loop=$related_objects show=$related_objects}
<li><a href={$ContentObject:item.main_node.url_alias|ezurl}>{$ContentObject:item.name}</a></li>
{/section}
</ul>
</div>
{/section}
{/let}