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! ;)

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

eZ debug

Timing: Jan 30 2025 21:13:39
Script start
Timing: Jan 30 2025 21:13:39
Module start 'layout'
Timing: Jan 30 2025 21:13:39
Module start 'content'
Timing: Jan 30 2025 21:13:39
Module end 'content'
Timing: Jan 30 2025 21:13:39
Script end

Main resources:

Total runtime0.0235 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.3594151.2266
Module start 'layout' 0.00530.0035 739.5859220.7266
Module start 'content' 0.00880.0134 960.31251,014.4922
Module end 'content' 0.02220.0013 1,974.804745.9766
Script end 0.0234  2,020.7813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002610.9961140.0002
Check MTime0.00104.4472140.0001
Mysql Total
Database connection0.00073.110410.0007
Mysqli_queries0.00239.987430.0008
Looping result0.00000.034510.0000
Template Total0.00104.110.0010
Template load0.00073.093110.0007
Template processing0.00020.941710.0002
Override
Cache load0.00052.104710.0005
General
dbfile0.002711.352680.0003
String conversion0.00000.030540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs