Problem with {section show=ne(...)}

Author Message

Tristan Koen

Thursday 07 August 2003 3:16:12 pm

I am having a problem that is driving me absolutely crazy. If there is anyone out there that can see what I am doing wrong, I would really appreciate it.

In my code I set a variable
{default myVar=47} where 47 is a specific node_id I want to exclude.

My code then goes:

{let folder_list=fetch(content, list, hash(parent_node_id, 47, sort_by, array(array(priority))))}
{section name=Folder loop=$folder_list}
<h1>{$Folder:item.name}</h1>

{let item_list=fetch(content, tree, hash(parent_node_id, $Folder:item.node_id, class_filter_type,exclude, class_filter_array,array(1), sort_by,array(array(published,false()))))}

{section loop=$Folder:item_list show=ne($:item.node_id,$myVar)}
Item node id: {$Folder:item.node_id} <br />
Latest node id: {$myVar} <br />

{/section}
{/let}

{/section}
{/let}

For some reason, I cannot get the {section show=ne(...)} bit to work. That particular node (it is an article) keeps getting displayed.

I am now getting desperate.

Regards,

Tristan

Jan Borsodi

Thursday 07 August 2003 10:32:37 pm

Try running the variable trough the ne operator instead of using it as parameters.
{section loop=$Folder:item_list show=$Folder:item.node_id|ne($myVar)}

Also look for errors and warnings in the debug list, they can give you clues to what is wrong.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Tristan Koen

Friday 08 August 2003 12:36:49 am

Hi Jan,

Thanks for the suggestion, but it still doesn't work.
There are no debug warnings or errors.
The cache has been cleared.

I have pasted the full source code below:
{default latest_item_id=0}

{* Fetch the latest article from the tree and assign its node_id to $latest_item_id *}
{let latest_article=fetch('content',tree,hash(parent_node_id, 47, sort_by,array(published,false())))}
{section loop=$latest_article max=1}
{set latest_item_id=$:item.node_id}
<h2>{$:item.data_map.title.content}</h2>
{$:item.data_map.intro.content.output.output_text}
<p><a href={concat('content/view/full/',$:item.node_id)|ezurl}>[ Read More... ]</a></p>
{/section}
{/let}

{* Fetch the list of folders contained in the library folder (node_id=47) *}
{let folder_list=fetch(content,list,hash(parent_node_id,47,sort_by,array(array(priority))))}
{section name=Folder loop=$folder_list}
<h1>{$Folder:item.name}</h1>

{* Fetch a list of all articles contained in each library folder. Exclude the article with node_id = $latest_item_id *}
{let item_list=fetch(content,tree,hash(parent_node_id,$Folder:item.node_id,class_filter_type,exclude,class_filter_array,array(1),sort_by,array(array(published,false()))))}
{section loop=$Folder:item_list max=1 show=$:item.node_id|ne($latest_item_id)}
Latest story id is {$latest_item_id}<br />
Current story id is {$:item.node_id}<br />
<h2>{$:item.data_map.title.content}</h2>
{$:item.data_map.intro.content.output.output_text}
<p><a href={concat('content/view/full/',$:item.node_id)|ezurl}>[ Read More... ]</a></p>
{/section}
<ul>
{section loop=$Folder:item_list offset=1}
<li><a href={concat('content/view/full/',$:item.node_id)|ezurl}>{$:item.data_map.title.content}</a></li>
{/section}
</ul>

{/let}
{/section}

{/let}

If anybody can see something wrong here, please PLEASE let me know.

Regards,

Tristan

Paul Forsyth

Friday 08 August 2003 1:52:47 am

Using 'show=ne($a,$b)' should work.

Can you perform some simple debugging on the values being tested.

Before your line:
{section loop=$Folder:item_list show=ne($Folder:item.node_id,$myVar)}

Try showing {$Folder:item.node_id} and {$myVar} so you can see the values before they are tested... This may help you see where the code logic is going wrong.

paul

Tristan Koen

Friday 08 August 2003 4:21:13 am

Sorry... I posted the wrong version of the code. I was playing with trying different namespaces and left some garbage in. I have corrected the code in the messages above.

The change is simple: I should have been comparing $latest_item_id with $:item.node_id instead of with $Folder:item.node_id (in my original code it was $Folder:sectionname:item.node_id but I dropped the section name).

It appears that the problem lies with variable scope rather than the ne() operator.
$:item.node_id appears to be null in the section declaration. It is only assigned within the {section}.

Is this the correct behaviour? This may be in the docs, but I couldn't find it...

Armed with this knowledge, I can make the code work by embedding a separate {section} within my looping {section}. Is there a better way to do this?

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