[LISE] check if field definition content empty
Posted: Fri Aug 14, 2020 12:12 pm
OK, I’m displaying entries by category with LISE like this:
I also have a field definition called “description” which is a WYSIWYG field. I’m now trying to check whether that field has any value and display the results differently depending on the condition, like in this example:
But whatever I do, it never seems to be empty, even if there is no content. Is there any special trick to this?
Code: Select all
<!-- category template -->
{if $categories > 0}
<section>
<h2>Title</h2>
<div class="categories">
{foreach $categories as $cat}
{$level = $cat->depth}
{$prevlevel = $cat->prevdepth}
{* close section *}
{if $level === 1 && $prevlevel === 2}
</section>
{/if}
{if $cat->fielddefs}
{$item = $cat}
{$fielddef = $cat->fielddefs}
<a href="{$item->url}">{CGSmartImage src="{$fielddef.image->GetImagePath(true)}/{$fielddef.image.value}" alt="{$item->title}" title="{$item->title}" filter_resize='h,100'}</a>
{else if $cat->items|count > 0}
<section class="category-{$cat->alias}">
<h3>{$cat->name}</h3>
{/if}
{/foreach}
{* close last section *}
</section>
</div>
</section>
{/if}
<!-- end category template -->Code: Select all
{$fielddef = $cat->fielddefs}
{if !empty($fielddef.description)}
has description
{/if}