Joomla Frontpage conditional


/ Published in: PHP
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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; ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.