[英]How to auto enable the plugin during installation in Joomla?
Does any good way in Joomla to auto enable the plugin during installation? Joomla 有什么好方法可以在安装过程中自动启用插件吗? I have followed the post topics but do not get any straight forward solution.
我遵循了帖子主题,但没有得到任何直接的解决方案。
I have used below code during installation for auto enabling the plugin :我在安装过程中使用了以下代码来自动启用插件:
UPDATE `#__extensions` SET `enabled` = 1 WHERE `element` = 'plugin_name';
But I want to know better solution.但我想知道更好的解决方案。
/Thanks /谢谢
That's the only way only way I'm aware of; 那是我所知道的唯一方法。 detailed below for others who might stumble on this trying to figure out how to do it.
下面详细介绍了其他可能会迷失方向的人,他们试图弄清楚该怎么做。
Add scripfile to the manifest (XML), below the </description>
tag: 在
</description>
标记下,将脚本文件添加到清单(XML):
<scriptfile>my_script.php</scriptfile>
my_script.php: my_script.php:
class PlgSystemPluginnameInstallerScript
{
public function install($parent)
{
// Enable plugin
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->update('#__extensions');
$query->set($db->quoteName('enabled') . ' = 1');
$query->where($db->quoteName('element') . ' = ' . $db->quote('PLUGIN_NAME_GOES_HERE'));
$query->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
$db->setQuery($query);
$db->execute();
}
}
Tip: If it's a content plugin, replace PlgSystemPluginnameInstallerScript
with PlgContentPluginnameInstallerScript
. 提示:如果是内容插件,
PlgSystemPluginnameInstallerScript
PlgContentPluginnameInstallerScript
替换为PlgContentPluginnameInstallerScript
。
There is no better solution. 没有更好的解决方案。 Joomla G+ group of Joomla developers
Joomla G +组的Joomla开发人员
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.