Ivan Zugec

Drupal Consultant

If and foreach in drupal templates

Examples of using if and foreach in drupal or general php templates:

<?php if($test == 1): ?>
do something
<?php endif; ?>

<?php if($test == 1): ?>
do something
<?php else: ?>
do something else
<?php endif; ?>

<?php foreach($items as $item): ?>
<?php echo $item->getTitle(); ?>
<?php endforeach; ?>

Category: 

Add new comment