1

Is there a way to check if in a Joomla! installation there are extensions from a specific vendor? In a plugin that i have i need to apply different procedures if a specific vendor products are present. Maybe querying db for author name? Please advise.

2

The author is saved in the manifest_cache in the #__extensions table. So you need to query the db to get that fields and the json_decode the values (or pass it into JRegistry) and look for the author.

  • Could you please take a look into my answer? Thanks – n.h. Jul 19 '15 at 19:01
2

Based on Bakual answer i came up with this code. This will only search for 'component' and 'template' type extensions.

$db = JFactory::getDbo();
$query = $db->getQuery(true);

$fields = array(
    $db->quoteName('extension_id'),
    $db->quoteName('manifest_cache')
);

$query->select($fields)->from($db->quoteName('#__extensions'));
$db->setQuery($query);
$vendors = $db->loadObjectList();

$extensions = array();

foreach($vendors as $vendor)
{
    $temp = new JRegistry;
    $temp->loadString($vendor->manifest_cache, 'JSON');

    $excList = array('joomla'); //This array will contain a extension list

    foreach($excList as $ext)
    {
        if ((stripos($temp->get('author'), $ext) !== false) && $temp->get('type') == 'component' || (stripos($temp->get('author'), $ext) !== false) && $temp->get('type') == 'template')
        {
            $extensions[] = array(
                'id'   => $vendor->extension_id,
                'type' => $temp->get('type'),
                'name' => $temp->get('name')
            );
        }
    }
}

made a test with 'joomla' as vendor name and generates a array like this

Array
(
[0] => Array
    (
        [id] => 1
        [type] => component
        [name] => com_mailto
    )

[1] => Array
    (
        [id] => 2
        [type] => component
        [name] => com_wrapper
    )

[2] => Array
    (
        [id] => 3
        [type] => component
        [name] => com_admin
    )

...

[29] => Array
    (
        [id] => 502
        [type] => template
        [name] => bluestork
    )

[30] => Array
    (
        [id] => 10067
        [type] => component
        [name] => com_joomlaupdate
    )
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.