/ Published in: PHP
                    
                                        
I set up an $isHome boolean variable at the beginning of a template's index.php file so I can easily test the condition throughout the file. To me, the semantic variable name makes the logic more readable.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
<?php
$menu = &JSite::getMenu();
$isHome = false;
if ($menu->getActive() == $menu->getDefault()) : $isHome = true;
endif;
// example use
if ($isHome) : ?>
<div>
<h1>You're HOME!</h1>
</div>
<?php else : ?>
<div>
<h1>You ain't home</h1>
</div>
<?php endif; ?>
URL: http://portal.hrpr.com/joomla-15-templates-conditional-statements
Comments
 Subscribe to comments
                    Subscribe to comments
                
                