Index: branches/5.0.x/core/units/categories/categories_event_handler.php =================================================================== diff -u -r12117 -r12231 --- branches/5.0.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 12117) +++ branches/5.0.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 12231) @@ -1,6 +1,6 @@ getObject(); // 2. preset template -// $object->SetDBField('Template', $this->_getDefaultDesign()); + $category_id = $this->Application->GetVar('m_cat_id'); + $root_category = $this->Application->findModule('Name', 'Core', 'RootCat'); + if ($category_id == $root_category) { + $object->SetDBField('Template', $this->_getDefaultDesign()); + } $priority_helper =& $this->Application->recallObject('PriorityHelper'); /* @var $priority_helper kPriorityHelper */ // 3. prepare priorities dropdown - $category_id = $this->Application->GetVar('m_cat_id'); $priority_helper->preparePriorities($event, true, 'ParentId = ' . $category_id); } @@ -1348,7 +1351,7 @@ } $page =& $this->Application->recallObject($this->Prefix . '.-virtual', null, Array ('page' => $t)); - if($page->isLoaded()) { + if ($page->isLoaded()) { $real_t = $page->GetDBField('CachedTemplate'); $this->Application->SetVar('m_cat_id', $page->GetDBField('CategoryId') ); if ($page->GetDBField('FormId')) { @@ -1399,6 +1402,12 @@ $this->_saveTitleField($object, 'Title'); $this->_saveTitleField($object, 'MenuTitle'); + + $root_category = $this->Application->findModule('Name', 'Core', 'RootCat'); + + if (($object->GetDBField('ParentId') == $root_category) && ($object->GetDBField('Template') == CATEGORY_TEMPLATE_INHERIT)) { + $object->SetError('Template', 'no_inherit'); + } } /** @@ -1682,6 +1691,9 @@ $design_sql = str_replace('(tf.FilePath = "/designs")', '(' . implode(' OR ', $design_folders) . ')' . ' AND (t.ThemeId = ' . $theme_id . ')', $design_sql); $fields['Template']['options_sql'] = $design_sql; + // adds "Inherit From Parent" option to "Template" field + $fields['Template']['options'] = Array (CATEGORY_TEMPLATE_INHERIT => $this->Application->Phrase('la_opt_InheritFromParent')); + $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); if ($this->Application->IsAdmin()) {