As the title suggests, I was wondering how to check if a certain plugin exists (and has been installed).
And secondly, check that the plugin is actually enabled.
As the title suggests, I was wondering how to check if a certain plugin exists (and has been installed).
And secondly, check that the plugin is actually enabled.
On top of checking within the admin area, there are some other ways you can do this, both in templates and in your plugins.
In a template
{# Second argument is if you want enabled only #}
{% set plugin = craft.plugins.getPlugin('pluginHandle', false) %}
{# Now you have access to these methods... #}
{{ plugin.isEnabled() }}
{{ plugin.isInstalled() }}
For a full list of methods, see PluginVariable in craft docs.
For more info on how to get plugins within your templates, see the PluginsVariable, note this is different from PluginVariable.
In your plugin
To check a plugin from within your own plugin:
// Again, second arg is if you just want enabled plugins
$plugin = craft()->plugins->getPlugin('pluginHandle', false);
// Then you can do things like:
$plugin->isInstalled
$plugin->isEnabled;
See the PluginService and also the BasePlugin for more info.
Hope that helps :)
onAfterInstall method on the plugin? that way you can always be sure the fieldtypes will be there and will also minimise user error, fieldtype handle mismatches and so forth.
– Alec Ritson
Jul 22 '15 at 13:52
pluginHandle corresponds to the directory name of the plugin? Couldn't find any documentation on this, but after a bit of trial and error that's what worked for me.
– Nick F
Oct 12 '15 at 15:11
For craft cms 3
{% set plugin = craft.app.plugins.getPlugin('plugin-handle', false) %}
{% if plugin is not null and plugin.isInstalled %}
....
call plugin related stuff here
.....
{% endif %}
To check plugin handle.
handle param in that file, that's the plugin handle.A simple way to check that a plugin is both installed and enabled is to use Twig's is defined test (since craft.pluginHandle is defined only if the plugin is both installed and enabled):
{% if craft.pluginHandle is defined %}
...
{% endif %}
(Credit due to this answer)
It should show up in the control panel in the plugins section. It will show the name of the plugin and if it is enabled. I've had issues when i didn't setup the folder correctly. Double check the plugin documentation, it should tell you what folder to place within the craft plugins directory.