Customizing Express Entry List (Condition if fields are empty)

I have an express entry list block that outputs data of consulting hours of teachers.

The following result items are displayed:
Consulting Time,
Consulting Room,
Consulting Room's Phone Number

I have put some HTML around the result items, maybe will also add classes.

If no consulting time (or an alternative text) is set in the field "ConsultingTime", it doesn't make sense to display the consulting room and it's phone number. Also no HTML should get rendered.

So i'm using an IF statement, like so:

<?php if ($item->getEntry()->getTeacherConsultingTime()) { ?>
   <div class="consulting-hours"><?php echo t('Consulting Hours:'); ?>
   <?php echo $item->getEntry()->getTeacherConsultingTime(); ?>
   <?php echo $item->getEntry()->getTeacherConsultingRoom(); ?>
   <?php echo $item->getEntry()->getTeacherConsultingRoomPhone(); ?>
<?php } ?>

While this is working as expected, i'm not sure if it's also best practice, or if there is a better way to set conditions if data are not available (express fields are empty), especially concerning the if statement that i'm using?

Thank you,

View Replies:
MrKDilkington replied on at Permalink Reply
Hi okapi,

At a glance, this looks fine.
okapi replied on at Permalink Reply
Cool, thanks for taking the time to confirm!