Using catalogs
There are three ways to get the catalog-tool working:
- Create an element ("Settings > "Catalogs").
- Create layouts ("Elements'-type layout and "Element"-type layout).
- Create a new page with the "Elements" layout.
1. Element-model field types:
String
(short text without a forming option)
Text
(text with a forming option)
Boolean
(true / false)
Image
(a picture url)
Select
(options)
Date
Code
- field name that is being used in the page layout to display the element attribute.
By the way, 'Title' field is required to save an element. Thats why we suggest to always add 'Title' to the title /
name field.
2. Layouts
"Elements"-type layout
It's necessary for creating new elements as well as displaying existing ones.
The button for creating elements:
{% addbutton element_type="Coffe" %}
Show elements:
{% for element in elements %}
<p><a href="{{ element.url }}">{{ element.title }}</a></p>
{% endfor %}
"Element"-type layout
Contains all of the fields that an element can have.
{% editable element.title %}
{% if editmode %}Description: {% endif %}<p>{% editable element.description %}</p>
By the way, we recommend adding titles to these fields so in the edit-mode you'll be able to make a difference in
between all of them.
Image-type field doesn't automatically create an image out of the image that has been dragged there but a text-field
instead. Please use the img-tag to display an image:
<img src="{{ element.image }}" alt="{{ element.title }}" />
3. Creating a page
First off, you need to have a page so you can then add elements with an 'Elements'-type layout.
Displaying elements not on a 'Elements'-type page.
Elementscontext, where the elements sources are being determined (from the page 'cataloguetool'):
{% elementscontext edicy_page_path_prefix="cataloguetool" %}
{% for element in elements %}
<p><a href="{{ element.url }}">{{ element.title }}</a></p>
{% endfor %}
{% endelementscontext %}