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.

eZ debug

Timing: Jan 18 2025 19:36:48
Script start
Timing: Jan 18 2025 19:36:48
Module start 'layout'
Timing: Jan 18 2025 19:36:48
Module start 'content'
Timing: Jan 18 2025 19:36:49
Module end 'content'
Timing: Jan 18 2025 19:36:49
Script end

Main resources:

Total runtime0.7945 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 587.9141152.6250
Module start 'layout' 0.00610.0040 740.539139.4453
Module start 'content' 0.01000.7830 779.9844613.1875
Module end 'content' 0.79310.0014 1,393.171916.1563
Script end 0.7945  1,409.3281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.3874160.0002
Check MTime0.00130.1602160.0001
Mysql Total
Database connection0.00090.115510.0009
Mysqli_queries0.727891.6099650.0112
Looping result0.00060.0702630.0000
Template Total0.760095.720.3800
Template load0.00190.239020.0009
Template processing0.758195.418620.3791
Template load and register function0.00030.035810.0003
states
state_id_array0.00110.144610.0011
state_identifier_array0.00170.212320.0008
Override
Cache load0.00170.2140810.0000
Sytem overhead
Fetch class attribute can translate value0.00060.072230.0002
Fetch class attribute name0.00090.118160.0002
XML
Image XML parsing0.00080.095730.0003
class_abstraction
Instantiating content class attribute0.00000.001460.0000
General
dbfile0.00090.1097170.0001
String conversion0.00000.001640.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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
18content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
14content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 40
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs