0

We're currently using this code to generate a class name that can be used to style a matrix block on the fly (ad-hoc):

{% for item in matrix.all() %}
<div class="page-builder__item-{{entry.id ?? ''}}-{{item.id}}">stuff here</div>
{% endfor %}

It appears that item.id can be temporary though and indeed, if a draft of an existing entry is created this id changes, breaking any styles applied to the previously generated class.

What can I use instead of the id to generate a class name which will not change?

Currently I am thinking of using dateCreated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.