Define variables in pagelayout.tpl, access in templates?

Author Message

Craig Hirsch

Wednesday 13 April 2005 1:54:36 pm

Okay, I want to set some site default variables in my pagelayout.tpl template, and access them arbitrarily within included templates. This seems to work fine as long as the templates from which I'm trying to access these vars are not invoked inside the output of $module_result.content. If they are, I can't get it to work.

Any ideas? Is it possible to have TRULY global vars in eZ?

--
chirsch{AT}gmail{d.t}com

Eivind Marienborg

Wednesday 13 April 2005 10:18:27 pm

I've never tried this, so I might be far off, but you could check out set-blocks:
http://www.ez.no/ez_publish/documentation/reference/template_functions/variables/set_block

And namespaces:
http://www.ez.no/ez_publish/documentation/development/libraries/ez_template/basics/namespaces

Craig Hirsch

Thursday 14 April 2005 11:10:11 am

Yup -- set_block seems like it should work, but it doesn't, if you're setting the var in the pagelayout and trying to access it from within $module_result.

Likewise with namespaces -- no success there either.

--
chirsch{AT}gmail{d.t}com

Kristian Hole

Thursday 14 April 2005 2:59:31 pm

The point here is that the module (example content) is run first. This means that if you set a variable in the pagelayout this will be set after your content view _already_ is rendered.

What are you trying to do? If these are sitedefault variables, the wise thing to do is to put it in a inifile and use the templateoperator ezini to read the values from there.

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Craig Hirsch

Thursday 14 April 2005 6:42:18 pm

Kristian, thanks for the inifile suggestion. That's actually exactly how I solved the problem -- I just declared a custom settings area in my site.ini.append, then stuck all of the required values in there.

--
chirsch{AT}gmail{d.t}com

Kristian Hole

Friday 15 April 2005 12:10:05 am

Good :)

Or if you want to, you might as well create a new inifile, and use the settings from that separate file.

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Xavier Dutoit

Friday 15 April 2005 4:58:35 am

Hi,

I have a problem related, but the otherway around:

In the content view, I want to set a global variable, so I can read it from pagelayout.

It works fine the first time, but (if I'm right) once the template is compiled, the content view doesn't set the global variable anymore.

Any idea ?

X+

http://www.sydesy.com

zaxofeel .v

Saturday 07 May 2005 7:34:24 am

just a simple question if you please:

is it possible to declare a variable in a template
like this
{set myvar=$node.node_id}

then call it in another page like that
{$myvar} ??

kracker (the)

Saturday 07 May 2005 7:47:48 pm

I could choke on these words, but ...
I thought that this was the problem that was causing all this strife ...

Xavier just mentioned it (above), that it was still in dier need of a clean room solution that didn't mean hacking apart your own life.

 It works fine the first time, but (if I'm right) once the template is compiled, the content view doesn't set the global variable anymore. Any idea ? X+
________________________
Please help me on to find a cache resistant method to exchange parameters between templates :
http://www.ez.no/community/forum/developer/how_to_exchange_parameters_between_several_parts_blocks_on_a_page

hrmm...
//kracker

<i>atmosphere : my song
sage francis : inherited scars</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

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