Categories Viewtool documentation for the dotCMS Content Management System

The Categories Viewtool provides methods to pull category information and related categories.

Methods

MethodReturn ValueDescription
init(Object obj)NoneItitalizes the Category object.
getChildrenCategoriesByKey(String key)ListReturns child categories for the key you passed in.
getCategoryByKey(String key)CategoryGives you the category for the ID that you passed in.
getCategoryByName(String name)CategoryGives you the category for the String name that you passed in.
getChildrenCategories(Category cat)ListReturns a list of the children categories of the category passed in.
getChildrenCategories(Inode inode)ListReturns a list of the categories that are the children of the category associated with the inode passed in.
getChildrenCategories(String string)ListReturns a list of the child categories of the category associated with the string passed in.
getChildrenCategories(String inode, boolean includeGrandChildren, int maxDepth)ListReturns a list of the child categories (and grand children depending on the boolean passed in) of the category associated with the string passed in up to the depth passed in.
getChildrenCategories(Category parentCategory, int level, int maxDepth)ListReturns a list of the child categories of the category including the children of the origional categories children up to the depth passed in.
getActiveChildrenCategories(Category cat)ListReturns a list of the active child categories for the parent category passed in.
getActiveChildrenCategoriesByKey(String key)ListReturns a list of the active child categories for the category associated with the key passed in.
getActiveChildrenCategories(Inode inode)ListReturns a list of the active child categories of the category associated with the inode passed in.
getActiveChildrenCategories(String inode)ListReturns a list of the active child categories for the parent category associated with the string passed in.
getActiveChildrenCategoriesOrderByName(Category cat)ListReturns a list of the active child categories in order by name for the parent category passed in.
getActiveChildrenCategoriesOrderByName(Inode inode)ListReturns a list of the active child categories in order by name for the parent category associated with the inode passed in.
getActiveChildrenCategoriesOrderByName(String inode)ListReturns a list of the active child categories in order by name for the parent category associated with the string passed in.
getActiveChildrenCategoriesByParent(ArrayList<String> o)ListReturns a list of the active child categories of each of the parent categories associated with the strings passed in.

The following example shows how the CategoriesWebAPI Viewtool is mapped in the toolbox.xml file:

    <tool>
        <key>categories</key>
        <scope>request</scope>
        <class>com.dotcms.rendering.velocity.viewtools.CategoriesWebAPI</class>
    </tool>