Forum
Check For Existence of Block
Is it possible to check for the existence of a block? For example:
article.html
<article<perch:if exists="image"> class="media"</perch:if>>
<h2><perch:content id="title" type="text" label="Title" title="true" /></h2>
<perch:blocks>
<perch:block type="image" label="Image">
<perch:template path="content/blocks/image.html" />
</perch:block>
</perch:blocks>
</article>
blocks/image.html
<img src="<perch:content id="image" type="image" label="Image" bucket="images" />" class="media__img" />
I'm using similar to the above but the "media" class never gets applied. Before switching to blocks I could test the image itself which would apply the appropriate styling, but it doesn't seem to work any more.
Thanks
What does
<perch:showall />
give you? I don't think it's going to be available, but this is all new stuff.This is the output:
Hmm, that's not ideal. That
_blocks
entry should ideally be flattened into something usable.Nothing that helps now, but I'll log it and see what we can do for a future update.
Alright that's great thanks :)