CategoryList class holds meta information about the category list and also an array of category items. It is this class that is used to interact with a category list.
Rather than instantiating the
CategoryList class directly it is preferable to use the
getLiveCategoryList function. This creates and returns an instance of
CategoryList, taking into account whether the category list is stored
in the database or as a file.
include_once 'egov/JaduCL.php'; $categoryList = getLiveCategoryList(BESPOKE_CATEGORY_LIST_NAME);
The parameter passed to the function is the name of the category list. This is stored in the
BESPOKE_CATEGORY_LIST_NAME constant. Once a
CategoryList has been instantiated then a number of functions are available to interact with it.
Get a category by id
CategoryItem class represents a single category. It has a constructor that sets default values and a few setter methods.
include_once 'egov/JaduCL.php'; $childCategories = $categoryList->getCategory($categoryID);
Get children of a category
include_once 'egov/JaduCL.php'; $childCategories = $categoryList->getChildCategories($categoryID);
Get the ancestors of a category
include_once 'egov/JaduCL.php'; $dirTree = $categoryList->getFullPath($categoryID);