bdListings.bdCategories
This is a user-contributed Extra. If you find issues or would like more info or help, please contact the author.
The bdCategories snippet can be used to output a dynamic category listing based on your categories in the bdListings component.
Snippet Properties
Property Name | Description | Default Value |
---|---|---|
limit | Number of categories to display, defaults to 0 (all categories). | 0 |
offset | Offset of categories to display, defaults to 0 (start with the first) | 0 |
sortby | [ name | description | parent | sortorder ] Field to sort on. | sortorder |
sortdir | [ asc | desc ] Sort direction | asc |
parent | ID of a category to list subcategories under. Defaults to 0 (top-level). | 0 |
includeSub | [ 1 | 0 ] When 1 this will also include subcategories (only if parent = 0)
|
1 |
subSeparator | Separator to use between individual sub categories. | - (space dash space) |
categorySeparator | Separator to use between individual categories. | line break (\n) |
tplCategory | Chunk (name) to use for displaying categories. Note that subcategories have a different template.
Placeholders you can use:
|
|
tplInner | Chunkname to use to wrap all subcategories in. The result of this is assigned to the subcategories placeholder in the tplCategory chunk. Could be used for <optgroup>s or some extra markup distinguishing subcategories.
Placeholders you can use:
|
|
tplOuter | Chunk (name) to use to wrap all the categories in. The value of this is returned by the snippet.
Placeholders you can use:
|
|
tplSub | Chunk (name) to use for displaying subcategories.
Placeholders you can use:
|
Examples
Minimum call:
[[!bdCategories]]
Categories Structure
- Different
- Something
- Something - Sub Category
Resulting HTML with default templates:
<h2>Categories</h2> <h3>Different</h3> <p></p> <h3>Something</h3> <p>sdfasdf?</p> <p>Subcategories: <a title="">Something - Sub Category</a></p>
Category Dropdown
Snippet call:
[[!bdCategories? &tplCategory=`bdl.cat.cat` &tplSub=`bdl.cat.sub` &tplInner=`bdl.cat.inner` &tplOuter=`bdl.cat.outer` &subSeparator=`` &includeSub=`1` ]]
bdl.cat.cat chunk:
<option value="[[+id]]">[[+name]]</option> [[+subcategories]]
bdl.cat.sub chunk:
<option value="[[+id]]">- [[+name]]</option>
bdl.cat.inner chunk:
[[+subcategories]]
bdl.cat.outer chunk:
<select name="category"> [[+wrapper]] </select>
Possible HTML output (depending on your category structure):
<select name="category"> <option value="1">Clowns</option> <option value="2">- Friendly Clowns</option> <option value="3">- Halloween Clowns</option> <option value="4">Animals</option> <option value="5">- Horse Riding</option> <option value="6">- Alpacas</option> <option value="8">Kino</option> </select>
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).