【发布时间】:2014-04-29 18:13:27
【问题描述】:
我正在努力解决这个问题。
安装 Joomla 2.5 插件时是否可以自动创建文件夹并将一些文件复制到其中?该文件夹应在图像(joomla 默认图像文件夹)/images/ 下创建,并且在用户安装插件时将一些文件复制到那里。
提前感谢您的帮助。
【问题讨论】:
标签: joomla joomla2.5 joomla-extensions
我正在努力解决这个问题。
安装 Joomla 2.5 插件时是否可以自动创建文件夹并将一些文件复制到其中?该文件夹应在图像(joomla 默认图像文件夹)/images/ 下创建,并且在用户安装插件时将一些文件复制到那里。
提前感谢您的帮助。
【问题讨论】:
标签: joomla joomla2.5 joomla-extensions
是的,这是可能的。您首先需要将以下代码添加到您的 XML 文件中:
<scriptfile>script.php</scriptfile>
然后创建一个名为 script.php 的文件并在其中添加以下代码:
<?php
defined('_JEXEC') or die('Restricted access');
class com_helloWorldInstallerScript {
function install($parent) {
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
//change this to the name of the folder you want to create
$newfolder = 'myfolder';
if(JFolder::create(JUri::root() . 'images/' . $newfolder)) {
//duplicate the line below as many times as you want for each file you want to move
JFile::move(JUri::root() . 'plugins/plugin_name/image.png', JUri::root() . 'images/' . $newfolder);
}
}
}
?>
希望对你有帮助
【讨论】: