I am building an education related app.
There are classes (as in a class in a classroom). The requirements call for being able to activate and deactivate classes as necessary.
Currently I have in my views:
<td>
<?php if($class->active == 1) :?>
<?php echo anchor( 'teachers/deactivate_class/'.$class->cid.'/'.$offset,
'Deactivate class', 'close_class#:'.$class->cid) ?>
<?php endif; ?>
<?php if($class->active == 0) :?>
<?php echo anchor( 'teachers/activate_class/'.$class->cid.'/'.$offset,
'Activate class', 'open_class#:'.$class->cid) ?>
<?php endif; ?>
</td>
I want to ask in the general case: Is there any way of using the PHP/Codeigniter syntax to merge this into one block with if/elseif/else if needed?
I found the example of how to use the single if in the CodeIgniter docs regarding the shopping cart. The doc isn’t really showing me anything else related with the exception of loops. Looking up the : for PHP on Google is just giving me the ternary operation…
It’s documented here: http://codeigniter.com/user_guide/general/alternative_php.html