Return to Snippet

Revision: 35204
at November 4, 2010 04:28 by beneberle


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

Revision: 35203
at November 4, 2010 04:24 by beneberle


Updated Code
<?php
$menu = &JSite::getMenu();
$isHome = false;
if ($menu->getActive() == $menu->getDefault()) : $isHome = true; 
endif;
?>

<?php
/*** example use

if ($isHome) : ?>
    <div>
       <h1>You're HOME!</h1>
    </div>
<?php else : ?>
    <div>
       <h1>You ain't home</h1>
    </div>
<?php endif;

****/
?>

Revision: 35202
at November 4, 2010 02:43 by beneberle


Initial Code
$menu = &JSite::getMenu();
$isHome = false;
if ($menu->getActive() == $menu->getDefault()) : $isHome = true; 
endif;

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

Initial Description
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.

Initial Title
Joomla Frontpage conditional

Initial Tags
joomla

Initial Language
PHP