Category Loop

Category loop lists categories from your shop.

{loop type="category" name="the-loop-name" [argument="value"], [...]}

Important informations :

* : argument is required
** : at least one of ** marked argument is required

Global arguments

Argument Description
backend_context

Determine if loop is use in backend context.

default : false

example : backend_context="on"

force_return

force return result for i18n tables even if there is no record

default : false

example : force_return="on"

limit

The maximum number of results to display.

example : limit="10"

name *

The loop name. This name must be unique and is used to reference this loop further in the page (see ifloop, elseloop or pageloop)

offset

The first product to display offset. Will not be used if `page` argument is set.

default : 0

example : offset="1"

page

The page to display.

example : page="2"

Text search arguments
Argument Description
search_in

A comma separeted list of field in which the search is performed

Possible values : title, chapo, description, postscriptum

example : search_in="title"

search_mode

the search mode : `any_word` (search any word separeted by a space), `sentence` (the sentence, anywhere in the field) or `strict_sentence` (the exact sentence)

default : strict_sentence

search_term

The term to search

example : search_term="my product"

Loop arguments

Argument Description
content
Thelia >= 2.3

One or more content ID. When this parameter is set, the loop returns the categories related to the specified content IDs.

example : content="3"

current

A boolean value which allows either to exclude current category from results either to match only this category

example : current="yes"

exclude

A single or a list of category ids.

example : exclude="2", exclude="1,4,7"

exclude_parent
Thelia >= 2.3

A single or list of categories id to exclude.

example : exclude_parent="12,22"

exclude_product

A single or list (since 2.3) product id to exclude.

example : exclude_product="3"

id

A single or a list of category ids.

example : id="2", id="1,4,7"

lang

A lang id

example : lang="1"

need_count_child

A boolean. If set to true, count how many subcategories contains the current category

default : false

example : need_count_child="yes"

need_product_count

A boolean. If set to true, count how many products contains the current category

default : false

example : need_product_count="yes"

not_empty

(**not implemented yet**) A boolean value. If true, only the categories which contains at least a visible product (either directly or through a subcategory) are returned

default : no

example : not_empty="yes"

order

A list of values

Expected values :
  • alpha : alphabetical order on title
  • alpha_reverse : reverse alphabetical order on title
  • created : ascending order on date of content creation
  • created_reverse : descending order on date of content creation
  • id : order by ascending ID
  • id_reverse : order by descending ID
  • manual : order by ascending position
  • manual_reverse : order by descending position
  • random : return categories in random order
  • updated : ascending order on date of content update
  • updated_reverse : descending order on date of content update
  • visible : online items firts
  • visible_reverse : offline items first

default : manual

example : order="random"

parent

A single or a list of category ids.

example : parent="3", parent="2,5,8"

product

A single or list (since 2.3) of product IDs.

example : product="3"

return_url
Thelia >= 2.3

A boolean value which allows the urls generation.

default : yes

example : return_url="no"

visible

A boolean value.

default : yes

example : visible="no"

with_prev_next_info

A boolean. If set to true, $PREVIOUS and $NEXT output arguments are available.

default : false

example : with_prev_next_info="yes"

Global outputs

Variable Description
$LOOP_COUNT the current results index, starting from 1
$LOOP_TOTAL the total number of results returned by the loop
$CREATE_DATE The creation date of this Category
$UPDATE_DATE The last modification date of this Category

Loop outputs

Variable Description
$CHAPO the category chapo
$CHILD_COUNT Number of subcategories contained by the current category. Only available if need_count_child parameter is set to true
$CREATE_DATE the category create date
$DESCRIPTION the category description
$HAS_NEXT true if a category exists after this one in the current parent category, following categories positions. Only available if with_prev_next_info parameter is set to true
$HAS_PREVIOUS true if a category exists before this one in the current parent category, following categories positions. Only available if with_prev_next_info parameter is set to true
$ID the category id
$IS_TRANSLATED check if the category is translated or not
$LOCALE the locale used for this loop
$META_DESCRIPTION the category meta description
$META_KEYWORD the category meta keyword
$META_TITLE the category meta title
$NEXT The ID of category after this one in the current parent category, following categories positions, or null if none exists. Only available if with_prev_next_info parameter is set to true
$PARENT the parent category
$POSITION the category position
$POSTSCRIPTUM the category postscriptum
$PREVIOUS The ID of category before this one in the current parent category, following categories positions, or null if none exists. Only available if with_prev_next_info parameter is set to true
$PRODUCT_COUNT Number of visible products contained by the current category. Only available if need_product_count parameter is set to true
$TEMPLATE >= 2.2 the template id associated to this category
$TITLE the category title
$UPDATE_DATE the category update date
$URL the category URL
$VERSION the category version
$VERSION_AUTHOR the category version author
$VERSION_DATE the category version date
$VISIBLE Return if the category is visible or not