Index: trunk/core/units/general/helpers/mod_rewrite_helper.php =================================================================== diff -u -N -r6791 -r7391 --- trunk/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 6791) +++ trunk/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 7391) @@ -286,26 +286,55 @@ */ function ProcessVirtualTemplate(&$url_parts, &$vars) { - if (!isset($url_parts[0]) || !$this->Application->isModuleEnabled('In-Edit')) return false; + if (!isset($url_parts[0])) return false; - $template_path = implode('/', $url_parts); - $sql = 'SELECT p.PageId, ci.CategoryId FROM '.TABLE_PREFIX.'Pages AS p - LEFT JOIN '.TABLE_PREFIX.'CategoryItems AS ci - ON ci.ItemResourceId = p.ResourceId - WHERE - Path = '.$this->Conn->qstr($template_path).' - AND - ci.PrimaryCat = 1 - AND - p.Status = 1'; - $template_found = $this->Conn->GetRow($sql); + if ($this->Application->isModuleEnabled('Proj-CMS')) { + $friendly = $this->Conn->GetRow( + ' SELECT CategoryId, NamedParentPath FROM '.TABLE_PREFIX.'Category + WHERE FriendlyURL = '.$this->Conn->qstr(implode('/', $url_parts))); + if ($friendly) { + $vars['m_cat_id'] = $friendly['CategoryId']; + $vars['t'] = preg_replace('/^content\//i', '', $friendly['NamedParentPath']); + return true; + } - if ($template_found) { - $vars['m_cat_id'] = $template_found['CategoryId']; - $vars['t'] = $template_path; - return true; + + $template_path = 'content/'.implode('/', $url_parts); + + $sql = 'SELECT CategoryId FROM '.TABLE_PREFIX.'Category + WHERE + NamedParentPath = '.$this->Conn->qstr($template_path).' + AND + Status = 1'; + $template_found = $this->Conn->GetRow($sql); + + if ($template_found) { + $vars['m_cat_id'] = $template_found['CategoryId']; + $vars['t'] = implode('/', $url_parts); + return true; + } } + if ($this->Application->isModuleEnabled('In-Edit')) { + $template_path = implode('/', $url_parts); + $sql = 'SELECT p.PageId, ci.CategoryId FROM '.TABLE_PREFIX.'Pages AS p + LEFT JOIN '.TABLE_PREFIX.'CategoryItems AS ci + ON ci.ItemResourceId = p.ResourceId + WHERE + Path = '.$this->Conn->qstr($template_path).' + AND + ci.PrimaryCat = 1 + AND + p.Status = 1'; + $template_found = $this->Conn->GetRow($sql); + + if ($template_found) { + $vars['m_cat_id'] = $template_found['CategoryId']; + $vars['t'] = $template_path; + return true; + } + } + return false; }