Index: trunk/core/units/general/helpers/mod_rewrite_helper.php =================================================================== diff -u -N -r8397 -r8901 --- trunk/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 8397) +++ trunk/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 8901) @@ -8,7 +8,7 @@ * @var kHttpQuery */ var $HTTPQuery = null; - + function kModRewriteHelper() { parent::kHelper(); @@ -308,16 +308,26 @@ $template_path = 'content/'.implode('/', $url_parts); - $sql = 'SELECT CategoryId FROM '.TABLE_PREFIX.'Category + $sql = 'SELECT CategoryId, IsIndex, NamedParentPath FROM '.TABLE_PREFIX.'Category WHERE LOWER(NamedParentPath) = '.$this->Conn->qstr($template_path).' AND Status IN (1,4) '; $template_found = $this->Conn->GetRow($sql); if ($template_found) { + // IsIndex = 2 is a Container-only page, meaning it should go to index-page child + if ($template_found['IsIndex'] == 2) { + $template_found = $this->Conn->GetRow(' + SELECT CategoryId, NamedParentPath FROM '.TABLE_PREFIX.'Category + WHERE ParentId = '.$template_found['CategoryId'].' AND IsIndex = 1 + '); + $vars['t'] = preg_replace('/^content\//i', '', $template_found['NamedParentPath']); + } + else { + $vars['t'] = implode('/', $url_parts); + } $vars['m_cat_id'] = $template_found['CategoryId']; - $vars['t'] = implode('/', $url_parts); $vars['is_virtual'] = true; // for template from POST return true; } @@ -365,7 +375,7 @@ $vars = $this->parseRewriteURL($url,$passed); $cache = array('vars'=>$vars,'passed'=>$passed); $this->Conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("mod_rw_'.md5($url).'", '.$this->Conn->qstr(serialize($cache)).', '.adodb_mktime().')'); - + if (isset($this->HTTPQuery->Post['t']) && $this->HTTPQuery->Post['t']) { // template from POST overrides template from URL. $vars['t'] = $this->HTTPQuery->Post['t'];