Index: branches/5.3.x/core/kernel/managers/url_manager.php =================================================================== diff -u -N -r15652 -r15677 --- branches/5.3.x/core/kernel/managers/url_manager.php (.../url_manager.php) (revision 15652) +++ branches/5.3.x/core/kernel/managers/url_manager.php (.../url_manager.php) (revision 15677) @@ -1,6 +1,6 @@ Application->GetVar('m_theme'); - } - if ( !$t ) { // when template not specified, use current $t = $this->Application->GetVar('t'); @@ -114,12 +108,9 @@ unset($params['use_section']); } - $theme_id = isset($params['m_theme']) ? $params['m_theme'] : $current_theme_id; - - if ( isset($use_section) && $use_section && array_key_exists($t . ':' . $theme_id, $this->structureTemplateMapping) ) { - // structure template corresponding to given physical template - $t = $this->structureTemplateMapping[$t . ':' . $theme_id]; - unset($params['use_section']); + if ( isset($use_section) && $use_section ) { + $theme_id = isset($params['m_theme']) ? $params['m_theme'] : null; + $t = $this->getSectionTemplate($t, $theme_id); } if ( preg_match('/external:(.*)/', $t, $regs) ) { @@ -366,10 +357,21 @@ */ public function getPhysicalTemplate($seo_template) { - $physical_template = array_search($seo_template, $this->structureTemplateMapping); + $physical_template = false; + $found_templates = array_keys($this->structureTemplateMapping, $seo_template); - if ( $physical_template === false || substr($physical_template, 0, 3) == 'id:' ) { - // physical template from ".smsignore" file OR virtual template + foreach ($found_templates as $found_template) { + if ( substr($found_template, 0, 3) == 'id:' ) { + // exclude virtual templates + continue; + } + + // several templates matched (physical and sym-linked to it) + $physical_template = $found_template; + } + + if ( $physical_template === false ) { + // physical template from ".smsignore" file return $seo_template; } @@ -405,6 +407,34 @@ } /** + * Returns section template for given physical/virtual template + * + * @param string $template + * @param int $theme_id + * @return string + * @access public + */ + public function getSectionTemplate($template, $theme_id = null) + { + static $current_theme_id = null; + + if ( !isset($current_theme_id) ) { + $current_theme_id = $this->Application->GetVar('m_theme'); + } + + if ( !isset($theme_id) ) { + $theme_id = $current_theme_id; + } + + if ( array_key_exists($template . ':' . $theme_id, $this->structureTemplateMapping) ) { + // structure template corresponding to given physical template + return $this->structureTemplateMapping[$template . ':' . $theme_id]; + } + + return $template; + } + + /** * Loads template mapping for Front-End * * @return void