"contains" isn't working

Author Message

tom riddle

Friday 03 June 2011 2:54:24 am

Hi there,

I tried the following, but it fails:

 

In my dummy.ini I have defined the following settings:

[Tag_Nodes]
PredefinedPageNodeIds[impressum]=765
PredefinedPageNodeIds[kontakt]=1288

 

Then in my pagelayout.tpl I defined:

{def $PredefinedPageNodeIds = ezini('Tag_Nodes','PredefinedPageNodeIds','dummy.ini')   
       $currentNodeId = $module_result.node_id}

 

When I try the following condition, I get always TRUE, what's wrong?

{if ($PredefinedPageNodeIds|contains($currentNodeId))}
  doSomehting...
{/if}

 

Thanks for every help, Tom.

SEBBANE Alexandre

Friday 03 June 2011 3:19:37 am

Hello

can you try without details in your array

i think contains work only with one dimension array...

let us know about this test.

 

Alex

Paris, France

tom riddle

Friday 03 June 2011 3:47:47 am

"

Hello

can you try without details in your array

i think contains work only with one dimension array...

let us know about this test.

 

Alex

"

I tried without details now:

PredefinedPageNodeIds[]=765
PredefinedPageNodeIds[]=1288

But it's still not working...

Tom

Marko Žmak

Friday 03 June 2011 3:59:17 am

First check if you have exact values in your variables. Try this:

{$currentNodeId}
{$PredefinedPageNodeIds|attribute(show)}

and see what do you get.

Also, the if condition shouldn't be in round brackets, so it should be like this:

{if $PredefinedPageNodeIds|contains($currentNodeId)}
  doSomehting...
{/if}

 

 

$PredefinedPageNodeIds

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

tom riddle

Friday 03 June 2011 4:17:27 am

"

First check if you have exact values in your variables. Try this:

{$currentNodeId}
{$PredefinedPageNodeIds|attribute(show)}

and see what do you get.

Also, the if condition shouldn't be in round brackets, so it should be like this:

{if $PredefinedPageNodeIds|contains($currentNodeId)}
  doSomehting...
{/if}
"

 

Ok, I've checked now:

 {$currentNodeId}

767

 {$PredefinedPageNodeIds|attribute(show)}
Attribute Type Value
0 string '765'
1 string '1288'

 

Then I removed the round brackets:

{else if $PredefinedPageNodeIds|contains($currentNodeId)}

But it's still TRUE...

 

------------------

SOLUTION:

It should be

{elseif $PredefinedPageNodeIds|contains($currentNodeId)}

and NOT

{else if $PredefinedPageNodeIds|contains($currentNodeId)}

There was a space between if and else...

 

Many thanks, Tom!

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 00:47:36
Script start
Timing: Jan 18 2025 00:47:36
Module start 'layout'
Timing: Jan 18 2025 00:47:36
Module start 'content'
Timing: Jan 18 2025 00:47:37
Module end 'content'
Timing: Jan 18 2025 00:47:37
Script end

Main resources:

Total runtime0.9610 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.0062 589.0391152.6250
Module start 'layout' 0.00620.0046 741.664139.4375
Module start 'content' 0.01070.9484 781.1016647.4922
Module end 'content' 0.95910.0018 1,428.593816.1797
Script end 0.9609  1,444.7734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3295160.0002
Check MTime0.00130.1309160.0001
Mysql Total
Database connection0.00070.073510.0007
Mysqli_queries0.870490.5755650.0134
Looping result0.00060.0581630.0000
Template Total0.929096.720.4645
Template load0.00190.201220.0010
Template processing0.927096.464120.4635
Template load and register function0.00020.019210.0002
states
state_id_array0.00130.135810.0013
state_identifier_array0.00110.119520.0006
Override
Cache load0.00190.19441130.0000
Sytem overhead
Fetch class attribute can translate value0.00060.061230.0002
Fetch class attribute name0.00140.141070.0002
XML
Image XML parsing0.00130.132230.0004
class_abstraction
Instantiating content class attribute0.00000.001370.0000
General
dbfile0.00110.1120240.0000
String conversion0.00000.001240.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
21content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
22content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
9content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/th.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/th.tplEdit templateOverride template
3content/datatype/view/ezxmltags/tr.tpl<No override>extension/community/design/community/templates/content/datatype/view/ezxmltags/tr.tplEdit templateOverride template
6content/datatype/view/ezxmltags/td.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/td.tplEdit templateOverride template
1content/datatype/view/ezxmltags/table.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/table.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 82
 Number of unique templates used: 13

Time used to render debug report: 0.0001 secs