Author
|
Message
|
Fou Jino
|
Tuesday 08 March 2011 7:00:12 am
Hey everyone, Is that possible to create a variable in pagelayout.tpl and pass this variable to others page across that : {$module_result.content} ?? Thanks in advance !
Foujino ~ http://www.foujino-blog.be
|
Damien Pobel
|
Tuesday 08 March 2011 7:17:56 am
Hi, that's not possible because the pagelayout is computed after the view template. You can do the opposite with the persistent variables mecanism or by using ezpagedata and ezpagedata_set operators if you have the ezwebin extension, see this message http://share.ez.no/forums/developer/add-to-persistent-variable-array#comment63760 Cheers
Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish
|
Greg McAvoy-Jensen
|
Tuesday 08 March 2011 7:20:33 am
Fou, Could you give an example of where you would like to pass the variable to? Pagelayout.tpl is run after the module, so $module_result is already finished being made before pagelayout is started. You'd need a time machine to pass things into module_result at that point. But pagelayout.tpl variables are certainly available to templates called with the include function.
Granite Horizon, Certified Developer of eZ Publish Web Solutions
Provider of the SaaS Solution Granite Horizon In The Cloud | http://granitehorizon.com/cloud
http://granitehorizon.com | +1 916 647 6350 | California USA | @granitegreg
Blog: http://granitehorizon.com/blog
|
Fou Jino
|
Tuesday 08 March 2011 8:29:43 am
Ok, in fact I think that I give you a bad explained My pagelayout.tpl receive a value that I have to use in others template : pagelayout.tpl : [...] <div id="content"> {$module_result.content} </div> [...] At the level {$module_result.content}, I have for example homepage.tpl : <div class="my-box"> [...] {if $var=[...]} {/if} [...] </div> Thus, I want to give the variable $var from the pagelayout.tpl.
Foujino ~ http://www.foujino-blog.be
|
Greg McAvoy-Jensen
|
Tuesday 08 March 2011 8:53:30 am
So you want to set $var is pagelayout.tpl and then read it in homepage.tpl, for example. Is that correct?
Granite Horizon, Certified Developer of eZ Publish Web Solutions
Provider of the SaaS Solution Granite Horizon In The Cloud | http://granitehorizon.com/cloud
http://granitehorizon.com | +1 916 647 6350 | California USA | @granitegreg
Blog: http://granitehorizon.com/blog
|
Fou Jino
|
Tuesday 08 March 2011 10:04:31 am
Yes, exactly Greg !
Foujino ~ http://www.foujino-blog.be
|
Greg McAvoy-Jensen
|
Tuesday 08 March 2011 12:16:53 pm
Fou, The technique you describe is impossible. The two process are run serially. The content module is executed, running the full view of the home page, running homepage.tpl. When that module is finished running, it ends, leaving behind $module_result. Then pagelayout.tpl is executed; all it can do with $module_result.content is display it. So while it is not possible to pass a variable from pagelayout.tpl to the module which is running, it probably is in fact possible to achieve the end result you desire another way. This is, after all, eZ Publish. So feel free to ask your question again, but describing the end result/user experience needed rather than the coding technique.
Granite Horizon, Certified Developer of eZ Publish Web Solutions
Provider of the SaaS Solution Granite Horizon In The Cloud | http://granitehorizon.com/cloud
http://granitehorizon.com | +1 916 647 6350 | California USA | @granitegreg
Blog: http://granitehorizon.com/blog
|
Fou Jino
|
Tuesday 08 March 2011 1:21:27 pm
Aie :( Ok I have another solution (and question) but it doesn't work :D I have a module, it initialize a session variable and redirect to racine of my site web I have 4 differents siteaccess (+ admin siteaccess) in my site and I use this configuration for session variable (in override site.ini) [Session] SessionNameHandler=default SessionNamePerSiteAccess=disabled So, for example if I am in \en\folder1\object1 and on this page I call my module, my module initialize a session variable and then redirect in \en. If I show my session variable in \en it's not showed, but if I change the siteaccess for exemple \de, on this siteaccess my session variable showed And finally, from my pagelayout the session variable is always showed I don't understand why my session variable is not showed on the siteacces which called my module ?? PS : sorry for my bad english :D
Foujino ~ http://www.foujino-blog.be
|
Gaetano Giunta
|
Tuesday 08 March 2011 3:29:49 pm
If this has no security implications, you can often pass data from pagelayout to module templates using a javascript variable.
Principal Consultant International Business
Member of the Community Project Board
|
Fou Jino
|
Wednesday 09 March 2011 12:12:53 am
Hi Gaetano, Yes it's an idea but not very securely, if I have a user with a browser without javascript activated But I worked with session and I guess that I found why it doesn't work ! In fact, my session configuration was in the site.ini of my extension. Now I add this session configuration in each site.ini of my 4 siteaccess and then I guess it works, I'm trying to test ! And now I'm trying to use session to pass my variable ! Thanks all for your help and for pass your knowledge about pagelayout to me
Foujino ~ http://www.foujino-blog.be
|
Fou Jino
|
Wednesday 09 March 2011 12:32:51 am
After testing, I still have a problem ... the session variable is not refreshed and show on the current siteaccess but on others siteaccess it's correctly showed ! :s Here my session configuration in all siteaccess without admin siteaccess : [Session] SessionNameHandler=default SessionNamePerSiteAccess=disabled SessionNamePrefix=myapply_ Do you know why ?
Foujino ~ http://www.foujino-blog.be
|
Fou Jino
|
Wednesday 09 March 2011 1:42:41 am
I resolve my probleme by disabling the static and view cache : [ContentSettings] StaticCache=disabled ViewCaching=disabled But I don't know if it's the good solution. In your opinion ?
Foujino ~ http://www.foujino-blog.be
|
Gaetano Giunta
|
Wednesday 09 March 2011 1:27:36 pm
Deactivating the view cache is very bad for performance, and something we always recommend not to do for real-life production sites. If your website only gets a few hundred hits per day, you will not feel the difference, but when traffic explodes, the server will definitely suffer...
Principal Consultant International Business
Member of the Community Project Board
|
Fou Jino
|
Wednesday 09 March 2011 2:15:30 pm
Yes I understand but, I don't know why, my session variable it doesn't showed because there is a refresh probleme If I desactivate the cache, the session variable it correctly refreshed and showed
Foujino ~ http://www.foujino-blog.be
|