Posted By

beneberle on 11/04/10


Tagged

joomla


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

undesigns
createinside


Joomla Frontpage conditional


 / Published in: PHP
 

URL: http://portal.hrpr.com/joomla-15-templates-conditional-statements

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.

  1. <?php
  2. $menu = &JSite::getMenu();
  3. $isHome = false;
  4. if ($menu->getActive() == $menu->getDefault()) : $isHome = true;
  5. endif;
  6.  
  7.  
  8. // example use
  9.  
  10. if ($isHome) : ?>
  11. <div>
  12. <h1>You're HOME!</h1>
  13. </div>
  14. <?php else : ?>
  15. <div>
  16. <h1>You ain't home</h1>
  17. </div>
  18. <?php endif; ?>

Report this snippet  

You need to login to post a comment.