"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.