/** * Avoids creating new categories if not found in the root taxonomy * It will get the right CategoryID link, or leave the FAQ without categories. */ public static function getCategoryByName(&$obj, $val, $record) { $val = trim($val); $root = FAQ::getRootCategory(); if (!$root || !$root->exists()) { return null; } $category = $root->getChildDeep(array('Name' => trim($val))); if ($category && $category->exists()) { $obj->CategoryID = $category->ID; $obj->write(); } }
/** * Expose variables to the template. */ public function SelectorCategories() { $baseCategories = array(FAQ::getRootCategory()); $categories = $this->getCategoriesForTemplate($baseCategories); return $categories; }