I've been working with Joomla's custom fields in an article override, but I'm not having any luck adding markup ONLY when a field is used. I have very limited knowledge of PHP.
Here's my statement:
<?php if(isset($this->item->jcfields[x]) === true && empty($this->item->jcfields[x]) === false): ?>
<div class="name"><?php echo $this->item->jcfields[x]->value; ?></div>
<?php endif; ?>
In my limited understanding this would seem to check if the field has content and is not empty. If true, display the second line that wraps the field value in a div. That works.
Conversely, if the field is empty, the second line should be skipped, which would not create the wrapping div.
In reality, the div is created either way.
What am I missing?