2

We have received below errors on the home page:

eZTemplate @ design/dffestival/templates/page_footer.tpl:8[6]:
Unknown template variable 'view_parameters' in namespace ''

In our pagefooter.tpl file have below code:

<div class="attribute-layout">
  {attribute_view_gui attribute=$footerNode.data_map.layout view_parameters=$view_parameters}
</div>

We are using eZ Publish Community Project 2012.6 version.

Could anyone explain why I can't retrieve the view_parameters variable and how to do retrieve it?

Thanks

Sunil

Alan Francis
  • 1,249
  • 11
  • 17
Sunil Game
  • 83
  • 5

2 Answers2

0

Maybe u should start here: http://www.ezpedia.org/ez/view_parameters

Remember view parameters are by default available only within the context of the content module and it's views.

All other modules (by default) do not support this feature.

The recommended alternative to view parameters in these situations would be using get / post parameters instead.

Or here: https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Templates/Basic-template-tasks/Custom-view-parameters

In some cases $view_parameters won't work, try $module_result.view_parameters there. So the example above will be: The color is: {$module_result.view_parameters.color}
The amount is: {$module_result.view_parameters.amount}

Or here (check "$module_result section"): https://doc.ez.no/eZ-Publish/Technical-manual/3.10/Templates/The-pagelayout/Variables-in-pagelayout

jtmielczarek
  • 578
  • 4
  • 9
  • Thanks for your reply it's works for me. We are using: https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Templates/Basic-template-tasks/Custom-view-parameters – Sunil Game Jan 13 '16 at 10:45
0

Short answer :

You are trying to retrieve the $view_parameters within the pagelayout (or a template included in it). This is not possible by design and this is completely normal.

Long answer :

View parameters are meant to be used from the views/templates which are used by the content module : for instance, when viewing a content from its alias URL or using its system URL like /content/view/full/2.

They are useful if you want to pass some parameters from the URL to the content view and they are taken into account by the cache system which is a very important thing to keep in mind (this is not the case when using "vanilla" GET parameters).

The main usage is for pagination, for instance : /content/view/full/2/(offest)/2/(limit)10

One of the best practices when developing with eZ Publish (legacy) is to ask yourself : why do you need to retrieve these parameters into your layout ? I guess that you want to control your global layout using them and this is not a good idea.

If you want to control the layout based on something which depends on the content, then I'll suggest to use persistent variables. You will basically use the ezpagedata_set operator in the content/view template and retrieve this value in your pagelayout with ezpagedata() | see https://doc.ez.no/doc_hidden/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Miscellaneous/ezpagedata_set

Last but not least, remember that the module result is computed before the pagelayout (simply because the pagelayout will include this result using $module_result.content).

foobar
  • 926
  • 6
  • 21