6

I'm not really familiar with Joomla, but I need to write a script that is supposed to list all the installed extensions and their version number, if possible. I've already done this for WordPress, TYPO3 and Drupal, but in Joomla this seems to be a pretty big pain in the ass from what I've seen so far because:

  • there are three types of extensions, located in three different folders
  • many extensions are present in all three folders upon installation (though the version number is usually found in only one of them)
  • the version number is not documented regularly, and if it is, it's not always in a consistent way. For example I downloaded the plugin "jNews". On the website, it say "8.5.1" but in the modules folder there is a .xml file "mod_jnews.xml" with the following content:

->

<extension type="module" version="1.5.0" ...>
...
<version>2.0</version>
...
</extension>

So what is it? 8.5.1? 1.5.0? 2.0? -

Having no experience with Joomla whatsoever, I find this pretty confusing, though it may also be a misunderstanding on my part.

What I actually want to know, though is: Is there are reliable way to get all installed Joomla extensions + their version just based on the folder structure and the files within? Or any other way to get this information through a script (Python in my case)?

0

1 Answer 1

4

Any extension that is installed, is stored in the database, in the #__extensions table. So you can run a simply database query to get the name and the manifest cache (which contains the version):

$db = JFactory::getDbo();

$query = $db->getQuery(true);

$query->select($db->quoteName(array('name', 'manifest_cache')))
      ->from($db->quoteName('#__extensions'));

$db->setQuery($query);

$results = $db->loadObjectList();

foreach ($results as $extension)
{
    $decode = json_decode($extension->manifest_cache);
    echo $extension->name . ' : ' . $decode->version . '<br>';
}

Note that the above will get all plugins, components, modules, templates, libraries and packages, including default Joomla extensions.

You can of course change which types of extensions you'd like to get. For example, if you only want to get components, change the query in the above code to this:

$query->select($db->quoteName(array('name', 'manifest_cache', 'type')))
      ->from($db->quoteName('#__extensions'))
      ->where($db->quoteName('type') . ' = ' . $db->quote('component'));

Hope this helps

1
  • 1
    This seems to be the best solution, and I'm glad that it's quite simple. I've actually wanted to avoid PHP due to compatibility reasons, but since Joomla requires PHP to be installed, insisting on not using it is kinda pointless. Thank you!
    – R.G.
    Sep 28, 2015 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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