Tuesday 26 February 2008 3:00:55 am
<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:
[pagelayout_subtree_news]
Source=pagelayout.tpl
MatchFile=pagelayout-subtree-news.tpl
Subdir=templates
Match[sub_tree]=/1/2/130/
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 ) )";
}
else
{
$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?
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.
|