Forums / Developer / Create a variable befor calling $module_result.content

Create a variable befor calling $module_result.content

Author Message

David Santiso

Sunday 27 March 2011 2:30:23 pm

Hi,

Is there any way to create a variable before calling $module_result.content that can be used in templates that are shown by $module_result.content?

Ivo Lukac

Monday 28 March 2011 12:45:07 am

The thing is that the "$module_result.content " is called first. Before the pagelayout. You can see it when listing used templates...

So basically you can create a variable only in the "content/view " logic.

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Ivo Lukac

Monday 28 March 2011 1:59:33 am

"

The thing is that the "$module_result.content " is called first. Before the pagelayout. You can see it when listing used templates...

So basically you can create a variable only in the "content/view " logic.

"

Forgot one simple way to create a variable :) - via view parameters

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

David Santiso

Monday 28 March 2011 2:11:13 am

The pagelayout.tpl template calls pagelayout_main.tpl and this shows $module_result.content.

$module_result.content shows 2zoneslayout1.tpl, but I want to send a variable to 2zoneslayout1.tpl template.

Ivo Lukac

Monday 28 March 2011 2:22:13 am

"

The pagelayout.tpl template calls pagelayout_main.tpl and this shows $module_result.content.

$module_result.content shows 2zoneslayout1.tpl, but I want to send a variable to 2zoneslayout1.tpl template.

"

Yes, it seems like it this in that order but actually it is not. Like I said, module is called first which produces $module_result variable. After that the pagelayout is called. And the $module_result.content variable is used.

So you can't do what you want directly.

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

David Santiso

Monday 28 March 2011 3:01:27 am

Yes ;)

I show a list of content in 2zoneslayout1.tpl, but I want to display diferent type of content depending on a variable. The problem is I can't use unordered variables, or pass to an include and GET and POST don't work.

I think I should add that variable when $module_result.content being built, but I don't how.

Thanks for your help,

Ivo Lukac

Monday 28 March 2011 3:07:57 am

"

Yes ;)

I show a list of content in 2zoneslayout1.tpl, but I want to display diferent type of content depending on a variable. The problem is I can't use unordered variables, or pass to an include and GET and POST don't work.

I think I should add that variable when $module_result.content being built, but I don't how.

Thanks for your help,

"

Why no view_parameters?

E.g. /your_url_to_node/(variable)/value

you will have it in full view as $view_parameters.variable

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

David Santiso

Monday 28 March 2011 4:03:10 am

Because I think I can't access the contents of $view_parameters.variable if it is already showing $module_result.content. is $view_parameters a pagelayout.tpl variable? true?

Ivo Lukac

Monday 28 March 2011 4:09:01 am

"

Because I think I can't access the contents of $view_parameters.variable if it is already showing $module_result.content. is $view_parameters a pagelayout.tpl variable? true?

"

You can access view_parameter "variable" in full view templates with: $view_parameters.variable

To access the same in pagelyaout use: $module_result.view_parameters.variable

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

David Santiso

Monday 28 March 2011 6:12:46 am

I've done this:

In 2zoneslayout1.tpl:

{$view_parameters.filter}
...
<a href={'/content/view/full/2/(filter)/3'|ezurl()}>Test</a>

In pagelayout.tpl:

{$module_result.view_parameters.filter}

And result is:

pagelayout.tpl shows "3" and 2zoneslayout1.tpl shows nothing.

I don't understand :S

Ivo Lukac

Monday 28 March 2011 6:33:12 am

"

In 2zoneslayout1.tpl:

{$view_parameters.filter}
...
<a href={'/content/view/full/2/(filter)/3'|ezurl()}>Test</a>
"

Hm, ezflow tpl could be a little tricky, try with the global variable: {$#view_parameters.filter}

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

David Santiso

Monday 28 March 2011 10:51:31 am

It works!

Thank you very much! ;)

eZ debug

Timing: Jan 18 2025 03:07:03
Script start
Timing: Jan 18 2025 03:07:03
Module start 'content'
Timing: Jan 18 2025 03:07:04
Module end 'content'
Timing: Jan 18 2025 03:07:04
Script end

Main resources:

Total runtime0.7601 sec
Peak memory usage4,096.0000 KB
Database Queries221

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 587.8594180.8203
Module start 'content' 0.00570.6471 768.6797677.2891
Module end 'content' 0.65280.1073 1,445.9688348.4297
Script end 0.7600  1,794.3984 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.4925210.0002
Check MTime0.00140.1884210.0001
Mysql Total
Database connection0.00070.093710.0007
Mysqli_queries0.657486.48372210.0030
Looping result0.00180.23702190.0000
Template Total0.736896.920.3684
Template load0.00190.249220.0009
Template processing0.734996.689020.3675
Template load and register function0.00010.016410.0001
states
state_id_array0.00070.087910.0007
state_identifier_array0.00070.085720.0003
Override
Cache load0.00190.25451060.0000
Sytem overhead
Fetch class attribute can translate value0.00120.159730.0004
Fetch class attribute name0.00120.1587130.0001
XML
Image XML parsing0.00090.121830.0003
class_abstraction
Instantiating content class attribute0.00000.0041180.0000
General
dbfile0.00220.2938280.0001
String conversion0.00000.000830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
12content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
21content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
20content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
20content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 89
 Number of unique templates used: 9

Time used to render debug report: 0.0002 secs