Forums / Setup & design / Template Override Conditions

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.

eZ debug

Timing: Jan 17 2025 22:57:53
Script start
Timing: Jan 17 2025 22:57:53
Module start 'content'
Timing: Jan 17 2025 22:57:54
Module end 'content'
Timing: Jan 17 2025 22:57:54
Script end

Main resources:

Total runtime1.4778 sec
Peak memory usage4,096.0000 KB
Database Queries213

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 587.7109180.8438
Module start 'content' 0.00541.2578 768.5547743.4375
Module end 'content' 1.26320.2145 1,511.9922344.4375
Script end 1.4777  1,856.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.2692210.0002
Check MTime0.00150.1013210.0001
Mysql Total
Database connection0.00080.051110.0008
Mysqli_queries1.377993.24392130.0065
Looping result0.00230.15832110.0000
Template Total1.446497.920.7232
Template load0.00190.129520.0010
Template processing1.444597.748820.7222
Template load and register function0.00010.006610.0001
states
state_id_array0.00120.081010.0012
state_identifier_array0.00220.145820.0011
Override
Cache load0.00170.1163520.0000
Sytem overhead
Fetch class attribute can translate value0.00150.101760.0003
Fetch class attribute name0.00090.0633120.0001
XML
Image XML parsing0.00250.166060.0004
class_abstraction
Instantiating content class attribute0.00000.0013140.0000
General
dbfile0.01400.9479540.0003
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 31
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs