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 » Overriding templates for a subtree of...

Overriding templates for a subtree of reused objects

Overriding templates for a subtree of reused objects

Friday 25 November 2011 6:37:28 am - 2 replies


So I have a content tree like:

- Folder 
- - Article 
- - Article 
- Folder
- - Article
- Mobile Folder
- - Folder (reused from above)
- - - Article (reused from above)
- - - Article (reused from above)
- - Folder (reused from above)
- - - Article (reused from above)

I know I can't use a Match[section] override for overriding templates for the Mobile subtree because I'm re-using objects from a different section.

I also tried a Match[parent_node] override by it didn't work. When I viewed the $node attributes for the nodes in the mobile subtree, it showed that the nodes had two parent nodes, I guess because I'm reusing the objects in a second location.

How can I override the templates for the nodes in the mobile subtree that are reusing objects from my main content tree?

Thanks in advance!


Friday 25 November 2011 7:16:21 am

Hello Josh,

Welcome to the eZ Community!

Why not use a separate design for your mobile siteaccess?

This should let you override those templates for only the mobile siteaccess without having to specify an override condition. Remember to place your override design in the proper order to ensure it overrides the default design templates (remember it only overrides the ones you create here).

Also I don't think that nodes -can- have two parent_node_id(s), nodes have locations and can have many different locations but only one main node (parent_node_id). So parent_node should work for you here. I would try again.


Also your not being specific about what templates exactly your trying to override, which matters, please be more specific.

Remember that 'content/view/*.tpl' templates do not support the parent_node match condition

While the 'node/view/*.tpl' templates do support the parent_node match condition.

Also I wonder if you could not use a different parent class than folder to contain the mobile site subtree say a class based on the folder class named 'Mobile Folder'. Then you could use 'parent_class' and 'parent_class_identifier' match conditions for 'node/view/*.tpl' templates. Which might be a better solution in some use cases.

I think you might also be able to use the 'url_alias' match condition in your current situation, re:

Also I wonder why you could not simply customize the default template use for all of the same class for example and within this template override test if the root of the node is Mobile Folder (say by some unique attribute, node_id for example) and display a different template instead if you find a match otherwise display the default template code (a big if statement would work). Though to do this you might need a custom cache block, with keys related to this check, I'm not certain.

Alternatively you can create a copy of your content object/node by creating a duplicate object/node in the mobile subtree based on a content object of a different class than your 'Article' class say called 'Mobile article' and populate it with all the article's object's content and publish it (perhaps with an object relation attribute linking back to the original non-mobile article object). You could do this fairly simply with a custom workflow event. I suggest this because the two template types I mention above both support the 'class' and 'class_identifier' match condition, also the 'section'  and 'section_identifier' condition would be able to be used at this point as well.

In your template fetches you also can specify a parameter to only fetch the results of main_node_only,

Can you explain in more detail the use case your trying to fulfill here? Are you trying to override the templates in the same siteaccess or separate siteaccess?

I also found the following older but somewhat related threads,


I hope this helps ...




Modified on Friday 25 November 2011 8:17:24 am by // Heath

Friday 25 November 2011 7:33:47 am

Hey Heath,

Thanks for the reply!

I'm trying to override the 'node/view/*.tpl' template in the same siteaccess.

But as you said, I think I might just use a separate siteaccess for the mobile version, that makes much more sense.



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

36 542 Users on board!

Forums menu

Proudly Developed with from