Template Override Conditions

Author Message

Marco Zinn

Saturday 05 March 2011 5:41:39 am

I like to override multiple nodes with the same "full-view" template.

As http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-override-conditions says, i cannot easily have more than one node ID in an override block. So, i duplicated the override block, which works.

To be more flexible, when new nodes are added (which should use the same template), i'd like to use the node name (e.g. "News") as an override condition. So, i do not have to edit override.ini all the time.

I don't want to introduce a new class for it (using "folders" currently). I know, that all nodes, that need to be overridden are at the same node tree level, are "folder" objects and will be names "news". But i do not know the parent node ID. Specifically, i want to have an override condition, which does not rely on Node IDs, so i do not need to tamper override.ini.

To complicate things, i need (an other) override for the (direct) child nodes of these (multiple) "news" nodes.

I tried to use Match[url_alias], but this requires, that i speficy the complete url.

I'd prefer to specify the Node name or the last part of the url_alias to find the correct nodes.

But

Match[url_alias]=*/news

does not seem to work.

Also

Match[node_name]=News

does not exist.

How do i solve this problem best?

Marco
http://www.hyperroad-design.com

André R.

Sunday 06 March 2011 7:08:17 am

You can see your options in eznodeviewfunctions.php, they are:

$keyArray = array( array( 'object', $object->attribute( 'id' ) ),
                           array( 'node', $node->attribute( 'node_id' ) ),
                           array( 'parent_node', $node->attribute( 'parent_node_id' ) ),
                           array( 'class', $object->attribute( 'contentclass_id' ) ),
                           array( 'class_identifier', $node->attribute( 'class_identifier' ) ),
                           array( 'view_offset', $offset ),
                           array( 'viewmode', $viewMode ),
                           array( 'remote_id', $object->attribute( 'remote_id' ) ),
                           array( 'node_remote_id', $node->attribute( 'remote_id' ) ),
                           array( 'navigation_part_identifier', $navigationPartIdentifier ),
                           array( 'depth', $node->attribute( 'depth' ) ),
                           array( 'url_alias', $node->attribute( 'url_alias' ) ),
                           array( 'class_group', $object->attribute( 'match_ingroup_id_list' ) ),
                           array( 'state', $object->attribute( 'state_id_array' ) ),
                           array( 'state_identifier', $object->attribute( 'state_identifier_array' ) ),
                           array( 'section', $object->attribute( 'section_id' ) ),
                           array( 'section_identifier', $sectionIdentifier ) );
(...)
$keyArray[] = array( 'parent_class', $parentClassID );
$keyArray[] = array( 'parent_class_identifier', $parentClassIdentifier );

Plenty of possibilities ;)

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Marco Zinn

Sunday 06 March 2011 10:21:05 am

André, thanks for the hint and link to the PHP source.

But i don't see, which of the options fits my situation here and how i should set up the block in the override.ini . Did i oversee an option? In particular, i dont' see, if e.g. "url_alias" can help me here.

By the way: Personally, i think, one should need need to find and read a PHP source code to find out how to "use" (in this case: configure & design) an ez Installation. The docs should be up to date and complete.

But, thanks anyway :)

Marco
http://www.hyperroad-design.com

André R.

Sunday 06 March 2011 12:34:47 pm

They are, it's just easier for me to lookup the source code.
The doc on this is here under node/view/*.tpl.

As for your original question, it sound to me like you should create a new class. Even if it has the same attributes like some other class you obviously present it in another way, so a different object type makes most sense (IMHO) and probably makes it a lot easier for your editors to deal with this as well.

Class inheritance would help here, but I don't see us getting time to implement that anytime soon.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Steven E. Bailey

Monday 07 March 2011 12:59:21 am

Are you willing to do a kernel hack for this?

I remember doing a hack to add sub_tree to the Match options but I'm not finding the code. If you're interested then I'll keep looking.

This is what I'm talking about:

http://share.ez.no/forums/developer/how-to-make-template-override-based-on-subtree/comment42703

Something similar can be done for name.

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Damien Pobel

Monday 07 March 2011 2:48:32 am

Hi,

Like André, the best approach would be to create custom class. In terms of design of content in eZ Publish, it's the best practice.

If really you do not want to do that, perhaps you can write some custom code in a content edit handler to assign a custom section or a custom object state depending on your condtions (the name News...) but it's longer to implement.

Cheers

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

Sebastiaan van der Vliet

Monday 07 March 2011 5:29:56 am

There is a new and improved version of the hack mentioned by Steve. It's especially handy for multilingual sites.

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.