joomlajoomla1.5joomla2.5joomla1.7joomla1.6

Check if extension installed without notice on fail


The method JComponentHelper::isEnabled('com_extension', true); checks if an extension is installed and returns a boolean.

The function will also throw an exception notice it the component is not installed due to the self::getComponent($option, $strict); in the same helper class.

Is there a way to avoid the notice if the component is not installed?


Solution

  • Check your database to see if the component is installed and enabled.

    $db = JFactory::getDbo();
    $db->setQuery("SELECT enabled FROM #__extensions WHERE name = 'component name'");
    $is_enabled = $db->loadResult();
    

    if the value of $is_enabled is 1, then your component is enabled.