Customizing Express Entry List (Condition if fields are empty)
Permalink
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:
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,
Michael
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:'); ?> <br> <?php echo $item->getEntry()->getTeacherConsultingTime(); ?> <br> <?php echo $item->getEntry()->getTeacherConsultingRoom(); ?> <br> <?php echo $item->getEntry()->getTeacherConsultingRoomPhone(); ?> </div> <?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,
Michael
At a glance, this looks fine.