How can check that Joomla component is active or not ?


In Joomla programming sometime you need to check that component is active or not. Because it is good practice to check first the component is active , instead of getting errors in module. JComponentHelper class has a useful function to perform this task. Following example will shows how to check.

if (!JComponentHelper::isEnabled('com_test', true)) {
return JError::raiseError(JText::_('Test Component Error Title'), JText::_('Test Component is not installed on your Joomla site'));
}

The above code will check that the component ‘com_test’ is active , if it returns false then if condition become true and Joomla will return an error message “Test Component is not installed on your Joomla site”.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s