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

eZ Community » Forums » Setup & design » Overriding templates for a subtree of...
expandshrink

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

Hey,

So I have a content tree like:

Root
- 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!

Josh

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.

Re: http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Objects/ezcontentobjecttreenode

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.

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-override-conditions

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: http://share.ez.no/forums/setup-design/different-layout-for-entire-subtree

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,

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/list#eztoc87605_0_0_7

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,

http://share.ez.no/forums/setup-design/template-override-conditions2
http://share.ez.no/forums/develop...e-template-override-based-on-subtree
http://share.ez.no/forums/setup-d...-multiple-section-template-overrides
http://share.ez.no/forums/develop...using-templates-from-another-section
http://share.ez.no/forums/setup-design/recursive-override
http://share.ez.no/forums/general/multiple-section-assignment
http://share.ez.no/forums/setup-d...lias-of-node-or-alias-of-parent-node
http://share.ez.no/forums/develop...ding-match-condition-to-override.ini

 

I hope this helps ...

 

Cheers,

Heath 

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.

Thanks!

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from