Recall a variable defined inside an included template from frontpage.tpl

Recall a variable defined inside an included template from frontpage.tpl

Tuesday 16 November 2010 3:27:42 am - 2 replies

Modified on Tuesday 16 November 2010 3:40:46 am by Lo' F.

Author Message

Lo' F.

Tuesday 16 November 2010 3:55:26 am

I must say.. this forum is lucky to me... sometimes only by posting, it gives me the idea !

Actually it's not the answer to my question, but I made it work somehow:

I just relocate the fetch and the variable declaration inside frontpage.tpl above the line where I include the external template. I use that variable in here as well as in frontpage.tpl and doing in this way both the templates takes the variable.

It works and that's quite ok for now but it would be great if I could make tail of why leaving things like before didn't give any result..!?

loredanaebook.it

Gaetano Giunta

Tuesday 16 November 2010 4:12:40 am

It did not work because of scoping.

Scoping in eZP templates has been defined "borderline blackmagic" in the past, and my advice about it is doing exactly what you found out on your own: define a var in the pagelayout, then it will be available later on in the included templates.

You can even set its value in the included template, and the new value will be available after the inclusion in the pagelayout itself.

One caveat really: try to fetch as little as possible in the pagelayout, as those fetches are executed on every page view.

Generally to reduce the number of pagelayout fetches cache-blcoks are used. But when doing so, you cannot used included templates anymore, unless they're included within the cache block.

Principal Consultant International Business
Member of the Community Project Board

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

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