Template warnings

Author Message

Peter Putzer

Saturday 03 March 2007 3:27:05 am

Since upgrading my templates to the new syntax, I get several warnings that don't seem to be critical, but which I'd nonetheless like to go away:

One is apparently caused by using {skip} exit a {foreach} loop.

Warning: eZTemplate	Mar 03 2007 12:14:31
Function "skip" is not registered

The others seem to be caused by recursive calls to a template (for different nodes of course), again in the context of a {foreach} loop. I've found an issue report which seems to have something to do with this, but according to http://issues.ez.no/IssueView.php?Id=9861&activeItem=2 it has been fixed a few months ago (I'm using 3.9.1rc1). Any ideas?

 Warning: eZTemplate:foreach	Mar 03 2007 12:14:31
Variable 'child' already exists.

Oh, and the warnings do go away if I use {section} instead.

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

Michael Maclean

Thursday 08 March 2007 3:27:00 am

Are you doing something like

{foreach $array as $thing}
{def $child=fetch('somethingorther')
...
{/foreach}

If you are using {def} inside a loop, that'll probably be the cause of the second warning at least. You should use {set} in cases like that where you are redefining an already-set variable.

eZpedia community documentation project | http://ezpedia.org

Peter Putzer

Thursday 08 March 2007 11:53:13 am

No, I'm using:

{foreach $array as $child}
     {recursive_call_to_the_same_template node=$child}
{/foreach}

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

Hans Melis

Thursday 08 March 2007 1:00:41 pm

Another possibility is that the template you're calling within the foreach loop also defines a variable $child. The included template opens in the scope of the calling template which means you can't reuse a variable name.

Hans
http://blog.hansmelis.be

Peter Putzer

Thursday 08 March 2007 1:05:34 pm

Yes, of course it does. It's a recursive call via node_view_gui. But surely {foreach} should handle recursive calls? There was a bug report, because it didn't, but that has been reported as fixed. That's why I asked in the first place.

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

Hans Melis

Thursday 08 March 2007 2:22:05 pm

The timeframe indeed suggests 3.9.1rc1 should contain the fix, but I'm seeing dark clouds packing above this one. I'm not familiar with this issue and I don't know the scope of it, but would you mind running your failing template with template compile enabled? Does it still fail in that case (but don't trust 1st run as that is the compiling run)?

Hans
http://blog.hansmelis.be

Peter Putzer

Thursday 08 March 2007 11:12:04 pm

It would seem that things do work, so my question was more like "Why do I get these warnings?" Although it would appear to me that my syntax was correct, I could be mistaken.

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

Dmitry Lakhtyuk

Tuesday 13 March 2007 9:45:24 am

it's a bug.
it's fixed in trunk(3.10.0alpha1) rev. 18361,
release/3.9.1(3.9.1) rev. 18362,
release/3.8.7(3.8.7) rev. 18363,
release/3.7.10(3.7.10) rev. 18364
release/3.6.12(3.6.12) rev. 18365

Denitsa M.

Tuesday 08 May 2007 1:28:18 am

I have a simmilar warnings, my code is something like this:

{foreach $array_vars as $var}
.................................
{foreach $variables as $Index=>$Variable}
.................................
{/foreach}
.................................
{/foreach}

and then the warnings are

Warning: eZTemplate:foreach May 08 2007 10:45:25
Variable 'Variable' already exists.

Warning: eZTemplate:foreach May 08 2007 10:45:25
Variable 'Index' already exists.

I suppose it's because the cycle is in a cycle and for each outer iteration the inner cycle variables are again used..... Is there any way to get that around? I mean, the template IS WORKING, but can i get it absolutelly warning free?

Iguana IT - http://www.iguanait.com

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