-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Improvement]: need a way to check if a pimcoreblock is empty - outside of the block #17930
Copy link
Copy link
Closed
Description
Improvement description
Let's say, you have the following DOM structure:
<div class="foo">
<div class="bar">
{% pimcoreblock 'block' %}
/* code */
{% endpimcoreblock %}
</div>
</div>
The elements "foo" and "bar" implement some styling, so I don't want to use these wrapper elements if the block is empty. Previously, I was able to do something like:
{% if not pimcore_block('block').isEmpty() %}
<div class="foo">
<div class="bar">
{% for i in pimcore_block('block').iterator %}
/* code */
{% endfor %}
</div>
</div>
{% endif %}
Now, my workaround looks like:
{% pimcoreblock 'block' %}
{% if _block.current == 0 %}
<div class="foo">
<div class="bar">
{% endif %}
/* code */
{% if _block.current == _block.count - 1 %}
</div>
</div>
{% endif %}
{% endpimcoreblock %}
But I think it's obvious that this is not a nice solution at all. I would therefore request a way to check whether a block has content or not.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for issues without a type.