I seem to be having some issues with my custom theme node.tpl files.
Where I have a custom field I use code like this:
<?php if (isset($content['field_myfield'])) { ?> <div class="myfieldclass"> <?php print render($content['field_myfield']); ?> </div> <?php } ?>
This obviously works on Drupal and has (afaik) been working up to now on my Backdrop sites.
Unfortunately now, when the field is empty I am still getting the markup on the page, where I should be seeing nothing:
<div class="myfieldclass"> </div>
Unsure if something has changed in core or if I've been doing it wrong. Could someone point out what the issue might be please?
Okay I've managed to locate the issue here.
My config files were messed up.
The "field.instance.node.nodetype.field_fieldname.json" files had this setting for the default value (where no default value had been set in the field config):
This appears to cause rows in the relevant database table to be inserted with a blank value column. My node template code returns positive because the row exists, although without value.
Upon checking with a fresh install of Backdrop the config files should have this code:
Not sure how the config files had got to this state, but hopefully this might help someone else in the future.