This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Setup & design » How to pass a content node to a...

How to pass a content node to a matching template

How to pass a content node to a matching template

Thursday 06 June 2013 8:35:24 pm - 3 replies


Can eZ Publish 4.x automagically resolve the appropriate template for a child node to render the node in the parent content without hardwiring the proper "child" template in the parent?

  • Site 1 (content class cc-1)
    • Content A0 (content class cc-A)
    • Content A1 (content class cc-A)
    • Content B0 (content class cc-B)
    • Site 1-1 (content class cc-2)
      • Content B1 (content class cc-B)
      • Content B2 (content class cc-B)
      • Content C0 (content class cc-C)
  • Site 2 (content class cc-1)
    • Content A2 (content class cc-A)
    • Content C1 (content class cc-C)

What I want is that eZ publish "knows" for Content of type content class B template cc_B.tpl has to be used and injected into the page (regardless if on page with content class cc-1 or cc-2) witjout having to enumerate all possible combinations in cc_1.tpl and cc_2.tpl.

We haven't found an option to do that in the template overwrite system. Somehow we are missing the modularity!
Can you point me in the right direction?

Thank you very much for your help!



Modified on Thursday 06 June 2013 8:36:21 pm by JT -

Thursday 06 June 2013 11:43:57 pm

 Not sure I get the requirements, but node_view_gui template function goes trough the override system, getting the "right" templates for child nodes. Just create custom "line"-view tpls for your nodes based on the conditions  you need. It seems the conditions you need are only based on content-type: definitely doable.

Monday 10 June 2013 3:24:05 pm

Ok, maybe i asked a bit to complicated or didn't mention some relevant keywords:

Unfortunately this is not possible to be done *in a template* by node_view_gui, because for an call of node_view_gui you have to manually select a view (it's a required paramter). But my question was spcifically ment to circumvent manually selecting the view in the template.

What I want to do is in the scope of a template. I want to call another template based on the override.ini (by resolving e.g. the content class or the node ID) by just calling something like '*_view_gui content_node=nodeA '.

So maybe that's indeed impossible - though I can not figure out why. This should be a pretty obvious usecase and requirement.


Maybe one of the following options is possible:

Can I get the name of a template which would be choosen –no matter if node or class override–, by eZ Publish for the view of a certain node via template operators or any eZ Class, e.g. ezTemplate?

I.e. if there is a node based override for node A pointing to the template nodeA.tpl then I want to get the value nodeA.tpl or nodeA. If there is a class override for content class cc-B pointing to the template content-B.tpl


I want to prevent hardcoding all existing content classes and the corresponding templates in a template because this information is defined in override.ini and the default rules.


I hope I could clearify the issue with the additional information.

Thanks again.

Tuesday 11 June 2013 12:37:10 pm

Q: why would you not be able to specify the desired view in your node_view_gui call? I have a hard time figuring any need leading to such requirement...

Imagine that you want a meta-ubergeneric-template which can be used to display many nested-menus types with a single tpl.

then you {include uri="design:metamenu.tpl" viewmodeforchildren="whatever"}

and in metamenu.tpl: {node_view_gui content_node=$item view=$viewmodeforchildren}

if then you want to go meta-meta, you could f.e., in node/view/whatever.tpl, include again a different tpl based on an attribute of the current node.

Last comment: if there's some "lost in translation" thing going on here, and you just want to use the "standard" view template for any content, that's just a matter of knowing how the default view mode is called: it is "full"

Modified on Tuesday 11 June 2013 12:38:08 pm by Gaetano Giunta


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from