2013-05-25, 06:31:47
(2013-05-25, 06:18:58)lnickel Wrote: So I take this code and make a component from it and call it it as a param in the get_nav function. Cool. Just dont know how to do the if/else
PHP code between <?php and ?>, HTML outside:
Code:
<li class="<?php echo $item->classes; ?>">
<?php if ($item->hasChildren) { ?>
<a href="<?php echo htmlspecialchars($item->link); ?>">
<?php echo htmlspecialchars($item->text); ?>
</a>
<?php } else { ?>
<?php echo htmlspecialchars($item->text); ?>
<?php } ?>
<?php if ($item->isOpen) { ?>
<ul><?php $item->outputChildren(); ?></ul>
<?php } ?>
</li>
You could of course also write the else-part simply as
Code:
<?php } else { echo htmlspecialchars($item->text); } ?>