This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

npdoesmc12147
npdoesmc12147

Hi, this is my first time seeking help here at OCMS forums. I'm working with a theme that uses plugins (e.g RainLab.Blog) in order for it to work. Is there any twig code/conditional statement if the plugin is disabled or not? It's very useful to display infos regarding the theme rather than redirecting it into an error page.

Thanks in advance.

Last updated

KurtJensen
KurtJensen

You should be able to do:

use System\Classes\PluginManager;

and then:

$manager = PluginManager::instance();
if ($manager->exists('rainlab.blog')) {
 // Do Stuff
}

or

if ($manager->isDisabled('rainlab.blog')) {
 // Do Stuff
}

See: https://github.com/octobercms/october/blob/9dc1b4d836c8147f7fc0b3f752efe10d70a491f2/modules/system/classes/PluginManager.php#L279

Last updated

npdoesmc12147
npdoesmc12147

That's weird. I put the code into the header partial and it shows: syntax error, unexpected '$manager' (T_VARIABLE), expecting function (T_FUNCTION) and the conflict is in the $manager = PluginManager::instance(); part.

KurtJensen
KurtJensen

You need to put it inside a method of a controller, component, or plugin class.

Gregbee
Gregbee

KurtJensen said:

You need to put it inside a method of a controller, component, or plugin class.

or maybe inside the dynamic page feature of page, layout or partial in function onStart()

Last updated

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.