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; ?>

About the author: Ivan Zugec
Ivan Zugec's picture

Ivan is a Sydney Australia based Drupal Developer with over 5 years experience.

Follow:
Category: 

Add new comment