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