Posts

Showing posts from February, 2011

Assigning CSS style on the body element in your template

<?php $active = JFactory:: getApplication ( ) -> getMenu ( ) -> getActive ( ) ; ?> <body class = "<?php echo $active->alias; ?> " >

Hiding Modules when a User Logs In

<?php // Get the user object $user = &JFactory::getUser(); // Now work out the User ID $userId = $user->get('id'); // Now hide the module if user is logged in if ($userId == 0) : // Now we break out of the PHP tags and display the JDOC tag to include the module ?> <jdoc:include type="modules" name="public-right" style="xhtml" /> <?php endif; ?>

Module Position in Joomla

Load One Module Position   <?php if ( $this -> countModules ( 'user1' ) ) : ?> <div id= "user1" > <jdoc: include type= "modules" name= "user1" style= "xhtml" /> </div> <?php endif ; ?>   Load Four Module Positions   <?php if ( $this -> countModules ( 'user1 or user2 or user3 or user4' ) ) : ?> <div id= "userModules" >   <?php if ( $this -> countModules ( 'user1' ) ) : ?> <div id= "user1" > <jdoc: include type= "modules" name= "user1" style= "xhtml" /> </div><!-- end user1 --> <?php endif ; ?>   <?php if ( $this -> countModules ( 'user2' ) ) : ?> <div id= "user2" > <jdoc: include type= "modules" name= "user2" style= "xhtml" /> </div><!-- end user2 -->

Detecting Logged In State in Joomla

  <?php $userattr = JFactory:: getUser ( ) ; $thisuser = $userattr -> get ( 'guest' ) ; if ( $thisuser == 0 ) { ?> // is this a guest user? //yes. do guest user stuff <?php } else { ?> //no. do logged-in user stuff <?php } ?>  

Detecting Frontpage in Joomla

  <?php if ( JRequest:: getVar ( 'view' ) == 'frontpage' ) { ?> <!-- display your home page HTML here --> <?php } else { ?> <!-- display your internal page HTML here --> <?php } ?>  

Set Title in Joomla

$this->setTitle($mainframe->getCfg('sitename') . ' - ' . $this->getTitle());