Joomla 如何在安装模块时在介质管理器中创建文件夹
嘿,我在Joomla制作我的第一个模块 我想在Joomla中创建一个新文件夹当有人安装“我的模块”时,将启动媒体管理器。我一直在四处寻找,发现了一些信息。但我就是不能让它工作。可能是因为信息可能是给老Joomla的!版本。或者我可能实施错了 无论如何,我想到了以下几点: mod_mymodule.xmlJoomla 如何在安装模块时在介质管理器中创建文件夹,joomla,joomla3.0,Joomla,Joomla3.0,嘿,我在Joomla制作我的第一个模块 我想在Joomla中创建一个新文件夹当有人安装“我的模块”时,将启动媒体管理器。我一直在四处寻找,发现了一些信息。但我就是不能让它工作。可能是因为信息可能是给老Joomla的!版本。或者我可能实施错了 无论如何,我想到了以下几点: mod_mymodule.xml <extension type="module" version="3.8.1" client="site" method="upgrade"> <files>
<extension type="module" version="3.8.1" client="site" method="upgrade">
<files>
<scriptfile>install.componentname.php</scriptfile>
</files>
</extension>
install.componentname.php
install.createmap.php
<?php
$destination = JPATH_SITE."/images/mynewmap";
JFolder::create($destination);
?>
有人能告诉我如何在Joomla 3中安装模块时将文件夹添加到媒体管理器(root/images)中吗?您需要一个script.php文件来执行安装任务: 下面是script.php的示例内容:
<?php
// No direct access to this file
defined('_JEXEC') or die;
class mod_helloWorldInstallerScript
{
function install($parent)
{
echo '<p>The module has been installed</p>';
}
function uninstall($parent)
{
echo '<p>The module has been uninstalled</p>';
}
function update($parent)
{
echo '<p>The module has been updated to version' . $parent->get('manifest')->version . '</p>';
}
function preflight($type, $parent)
{
echo '<p>Anything here happens before the installation/update/uninstallation of the module</p>';
}
function postflight($type, $parent)
{
echo '<p>Anything here happens after the installation/update/uninstallation of the module</p>';
}
}
你能详细解释一下为什么我应该用postflight方法而不是install方法创建新文件夹吗?因为这样一切都成功了,你可以完成最后的安装步骤。但最终,这取决于你。好吧。我将把它添加到安装方法中,因为我只想在安装时添加该文件夹。我假设postflight也会在更新和卸载后运行代码,这是我不想要的。谢谢回复。你永远不知道人们在做什么。所以每次更新都会修复丢失的文件夹。