Share » Forums » Setup & design » Problem with {section show=ne(...)}

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

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

Thursday 07 August 2003 3:16:12 pm - 4 replies

Modified on Friday 08 August 2003 4:22:16 am by Tristan Koen

Author Message

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?

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu