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 » Developer » how to make template override based...

how to make template override based on subtree?

how to make template override based on subtree?

Thursday 31 March 2005 3:25:46 pm - 5 replies

I have 2 sections:

-Public - this section is accessible to everyone.
-Protected - this section is accessible only to registered users.

I made different templates for both sections:
- in Public section users can see only preview of article
- in Protectes section registered users can see full view of article

I put all articles to protected section, and for some articles I added locations to public section.

Problem: shared articles in public section are shown using templates from Protected section

Someone offered to make "template override based on subtree". How to make it? Where to find information about it, because i cannot find nothing simmilar in

Thursday 31 March 2005 3:54:06 pm

Hi vytis,

Check out this thread by Bård:

Friday 01 April 2005 8:51:47 am

i did not found clear description, how to use that mystical url_alias... sad.gif Emoticon

I made:



but nuw products in page /index.php/shop/produktai__3/indu_prieziura
are shown using default template, neither line/product.tpl nor product_line_klientams.tpl

Wednesday 20 April 2005 9:49:08 am

I have answered a similar question in the thread:

This should contain the information needed about subtree override.


Wednesday 20 April 2005 10:54:35 am

I checked
and other , but oneone answered to my question sad.gif Emoticon

My conclusion i see that Match[url_alias] does NOT work. It does the same as Match[node].
I posted some bugs according this this or close related problems:

So, as i see for the moment, eZ do not anything for applying templates for the tree. sad.gif Emoticon
Or does it?

i have such situation (simplified):

news (section0)
|____Folder1 (section1)
|    |____Article1 (section1)
|____Folder2 (section2)
    |____Article2 (section2)
Hardware (section1)
Software (section2)

section0 must have red backgroud and show preview information with small images
section1 must have green backgroud and original layout with big images
section2 must have blue backgroud and different layout

Articles to section0 are added using "add new location". And are dicplayed using style from original location.

so to apply template of section0 to news/Folder1/Article1 i tried to write


Nothing works. it started to work, only if i specified :


It works, only if i specify exact url to article, but this has no sense, because everything in folder news (section0) are changed every day. So i cannot change overrides every time i enter something new in news...

Tuesday 26 February 2008 12:00:55 pm

<b>sub_tree match override</b>

<i>Match on [url_alias]: issues in a multilingual site</i>
Using the [url_alias] as an match condition for the override system turned out to be problematic when used on a multilingual website. We ran into several problems. The first issue is related to the management of the override.ini.append.php file. We are using a sym linked override.ini.append.php file for the various siteaccesses (one siteaccess per language), in order to simplify maintenance of the site. Using the url_alias meant we had to set up separate url_alias matches for the various languages, either as separate override files per language, or additional entries in the shared override file (sym linked file). The second issue had to do with special characters in the url_alias: for some reason these were not picked up correctly from the override.ini.append files per language (in particular Polish) when using utf8_unicode_ci. We considered only using English nice urls, but it appeared not to be possible to disable the translated nice urls.

<i>Match on [sub_tree]</i>
In order to avoid the issues related to the translations of url_aliases, we have modified the kernel files to allow for a match condition on sub_tree:


The subtree value is referring to the 'path_string' field in the 'ezcontentobject_tree', and is a value that is shared across the various languages. The numbers between de slashes represent the node_ids

We modified the following files:

In kernel\classes\eznodeviewfunctions.php (ezp version 3.10.0) we added array( 'sub_tree', $node->attribute( 'path_string' ) ), to the $keyArray that starts at line 93 and $contentInfoArray['sub_tree'] = $node->attribute( 'path_string' ); to the $contentInfoArray that starts at line 176. In addition, we added array( 'sub_tree', $Result['content_info']['sub_tree'] ), to the $keyArray that starts at line 383.

In kernel/common/eztemplatedesignresource.php at line 522, directly after the match condition for the url_alias, we added a match condition for subtree in a else if statement:

 if ( $conditionKey == 'url_alias' )
                                    $matchCondition .=
                                        "( strpos( \$matchKeys[\\'url_alias\\'],  \\'" . $customMatch['conditions']['url_alias'] . "\\' ) === 0 ) )";
                                } else if ($conditionKey == 'sub_tree' )
                                	 $matchCondition .=
									    "( strpos( \$matchKeys[\\'sub_tree\\'],  \\'" . $customMatch['conditions']['sub_tree'] . "\\' ) === 0 ) )";

                                    $matchCondition .=
                                        "( is_array( \$matchKeys[\\'$conditionKey\\'] ) ? " .
                                        "in_array( \\'" . $customMatch['conditions'][$conditionKey] . "\\', \$matchKeys[\\'$conditionKey\\'] ) : " .
                                        "\$matchKeys[\\'$conditionKey\\'] == \\'" . $customMatch['conditions'][$conditionKey] . "\\') )";

Possibly the file kernel\classes\ezcontentcache.php also needs to be modified, by adding 'sub_tree' => [some value], to the $contentInfo array at line 237.

Can anybody think of any negative implications of these modifications?


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

36 542 Users on board!

Forums menu

Proudly Developed with from