Check if list elements exist before calling foreach #118

This commit is contained in:
Linard Schwendener 2019-12-08 20:46:20 +01:00
Родитель aa67751be1
Коммит 936ed1c43d
1 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -49,27 +49,27 @@
<aside>
<ul>
<h3><?php p($l->t('Tools')); ?></h3>
<?php foreach($_['tool'] as $tools) { ?>
<li><?php echo $tools; ?></li>
<?php } ?>
<?php if(isset($_['tool']) && $_['tool']) { ?>
<?php foreach($_['tool'] as $tool) { ?>
<li><?php echo $tool; ?></li>
<?php }} ?>
</ul>
<ul>
<h3><?php p($l->t('Ingredients')); ?></h3>
<?php if(isset($_['recipeIngredient']) && $_['recipeIngredient']) { ?>
<?php foreach($_['recipeIngredient'] as $ingredient) { ?>
<li><?php echo $ingredient; ?></li>
<?php } ?>
<?php }} ?>
</ul>
</aside>
<main>
<ol>
<h3><?php p($l->t('Instructions')); ?></h3>
<?php if(isset($_['recipeInstructions']) && $_['recipeInstructions']) { ?>
<?php foreach($_['recipeInstructions'] as $step) { ?>
<li><?php echo nl2br($step); ?></li>
<?php } ?>
<?php }} ?>
</ol>
</main>