当用户在Joomla Administrator中安装扩展时,Joomla扩展有可能自动在图像-> / images /events/下创建一个文件夹(事件)吗?
发布于 2011-03-16 00:49:07
您可以在扩展的清单文件[1,2]中指定在安装扩展时运行的自定义php脚本。这个脚本可以创建你的文件夹/images/events/。
joomla 1.5和1.6之间的安装程序有一些不同:
1.5
的<installfile/>部分
1.6
的部分
..。我看到另一个答案已经发布了。看看1.5版;1.6版,使用,看看http://docs.joomla.org/Developers,特别是http://docs.joomla.org/How_to_use_the_filesystem_package。文件夹的实际创建留给读者作为练习。
发布于 2011-03-16 00:41:27
在组件的xml文件中,您需要添加以下属性:
<installfile>install.componentname.php</installfile> 替换为组件的名称,这可以添加到组件安装xml文件的description属性下面。
添加后,您将需要创建一个名为"install.componentname.php“的文件,再次将componentname替换为您的组件的名称。
在此文件中添加以下内容:
<?php
// no direct access
defined('_JEXEC') or die('Restricted Access');
// import joomla's filesystem classes
jimport('joomla.filesystem.folder');
// create a folder inside your images folder
if(JFolder::create(JPATH_ROOT.DS.'images'.DS.'events')) {
   echo "Folder created successfully";
} else {
   echo "Unable to create folder";
} ?>将其打包并安装,install..php文件应该位于压缩文件的顶层。最后,您需要将此文件添加到您的组件文件列表中,就在属性之后添加以下行:
<files>
<filename>install.componentname.php</filename>
</files>如果文件夹创建成功,则会显示文件夹创建成功。
发布于 2012-01-07 23:54:36
<!-- Site Main Media File Copy Section -->
    <media destination="com_helloworld">
        <filename>image.png</filename>
        <filename>flash.swf</filename>
    </media>http://docs.joomla.org/Components:xml_installfile
https://stackoverflow.com/questions/5314086
复制相似问题