Category tree Loop

Category tree loop, to get a category tree from a given category to a given depth.

{loop type="category-tree" 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"

Loop arguments

Argument Description
category *

A single category id.

example : category="2"

depth

The max depth

example : depth="5"

exclude

A single or a list of category ids to exclude for result.

example : exclude="5,72"

return_url
Thelia >= 2.3

A boolean value which allows the urls generation.

default : yes

example : return_url="no"

visible

Whatever we consider hidden category or not.

default : true

example : visible="false"

Global outputs

Variable Description
$LOOP_COUNT the current results index, starting from 1
$LOOP_TOTAL the total number of results returned by the loop

Loop outputs

Variable Description
$CHILD_COUNT
$ID the category id
$LEVEL
$PARENT the parent category
$PREV_LEVEL
$TITLE the category title
$URL the category URL
$VISIBLE whatever the category is visible or not
I want to display a select list with all visible categories.
<select name="category">
    {loop name="categories-tree" type="category-tree" category="0"}
        <option value="{$ID}">{"-"|str_repeat:$LEVEL} {$TITLE} {if $CHILD_COUNT != 0}({$CHILD_COUNT}){/if}</option>
    {/loop}
</select>