menu

SiteGenesis / Server-side JS / Module: models/CategoryModel

Model for category functionality.

module:models/CategoryModel

The category class

Source:
Source:

Classes

CategoryModel

Methods

(inner) CategoryModel/get(parameter) → {module:models/CategoryModel~CategoryModel}

Gets a new instance of a given category.

Parameters:
Name Type Description
parameter dw.catalog.Category | String

The category object to enhance/wrap or the category ID of the category object.

Source:
Returns:

A new CategoryModel instance.

Type
module:models/CategoryModel~CategoryModel

(inner) CategoryModel/getMenuCategories(renderAllCategories) → {Array}

Gets a list of online categories that have the showInMenu attribute set to true. The showInMenu attribute is a custom attribute for SiteGenesis that determines whether a category is shown in the site navigation.

Parameters:
Name Type Description
renderAllCategories Boolean

Returns all online subcategories if true.

Source:
Returns:

Subcategories for menu.

Type
Array

(inner) CategoryModel/getTopLevelCategories() → {Collection|ArrayList}

Returns top level online categories list if it exists, otherwise returns sibling online categories list if it exists. If neither exist, it returns an empty list.

Source:
Returns:

Returns a collection of online subcategories or an empty list if there are no top level categories.

Type
Collection | ArrayList

(inner) CategoryModel/getTopLevelCategory() → {dw.catalog.Category}

Returns the root category from the site catalog.

Source:
Returns:

The root catalog category.

Type
dw.catalog.Category

(inner) CategoryModel/getUrl() → {dw.web.URL}

Prints out the category's alternative URL if maintained in a custom attribute. Uses custom attribute of type MarkupText to be able to maintain URLUtil-styled URLs, such as $url('GiftCert-Purchase')$

Source:
Returns:

URL for the Search controller Show function with the category ID.

Type
dw.web.URL