+91-40 – 420 001 24 info@dhrusya.com

Joomla development tips and hacks

Add styles and scrtpts to your extension

$cssUrl=Juri::base() . ‘components/com_component/assests/style.css’;
$jsUrl=Juri::base() . ‘components/com_component/assests/js.js’;

$document = JFactory::getDocument();
$document->addStyleSheet($jsUrl);
$document->addScript($jsUrl);

To display system messages :

   //Standard message
    JFactory::getApplication()->enqueueMessage($mymessage);

    //Notice message
    JError::raiseNotice(100, $mymessage);

    //Warning message
    JError::raiseWarning( 100, $mymessage );

So while programming you need to send a URL variable e.g. ?message=success and in my template/extension file simply made an if statement like this:

    if($_GET["message"] == "success") {
            $displaymsg = "My message text..";
            JFactory::getApplication()->enqueueMessage($displaymsg);
    }

Send email in Joomla :

//mailcode
$mailer = JFactory::getMailer();
$config = JFactory::getConfig();
$sender = array(
$config->get( ‘mailfrom’ ),
$config->get( ‘fromname’ ),
$config->get(‘sitename’) );

$mailer->setSender($sender);
$mailer->addRecipient($email);
$mailer->setSubject(“Subject”);
$mailer->setBody($msg);
$mailer->isHTML(true);
$send = $mailer->Send();
if($send){                                 }