教程:如何创建一个MVC模式的组件(六) 创建 hello.xml

本文介绍如何通过创建XML安装包来安装Joomla组件。详细解释了XML文件的结构及其所包含的各种元素,如组件基本信息、文件复制指令等,并提供了具体文件实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

打包 - 创建 hello.xml

可以通过上传文件,然后修改数据表来安装组件。更有效的方式是创建一个安装包,让Joomla installer帮你做安装。 这个安装文件包含以下内容:

组件的基本信息
要拷贝的文件
执行安装和卸载的php文件.
sql语句

xml文件格式如下:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/component-install.dtd">
<install type="component" version="1.5.0">
 <name>Hello</name>
 <!-- The following elements are optional and free of formatting conttraints -->
 <creationDate>2007 02 22</creationDate>
 <author>John Doe</author>
 <authorEmail> john.doe@example.org 为防备电子邮件地址收集器,这个 E-mail 地址被隐藏,你的浏览器必须支持 Javascript 才可看到这个邮件地址 </authorEmail>
 <authorUrl>http://www.example.org</authorUrl>
 <copyright>Copyright Info</copyright>
 <license>License Info</license>
 <!--  The version string is recorded in the components table -->
 <version>Component Version String</version>
 <!-- The description is optional and defaults to the name -->
 <description>Description of the component ...</description>

 <!-- Site Main File Copy Section -->
 <!-- Note the folder attribute: This attribute describes the folder
      to copy FROM in the package to install therefore files copied
      in this section are copied from /site/ in the package -->
 <files folder="site">
  <filename>index.html</filename>
  <filename>hello.php</filename>
  <filename>controller.php</filename>
  <filename>views/index.html</filename>
  <filename>views/hello/index.html</filename>
  <filename>views/hello/view.html.php</filename>
  <filename>views/hello/tmpl/index.html</filename>
  <filename>views/hello/tmpl/default.php</filename>
 </files>
 
 <administration>
  <!-- Administration Menu Section -->
  <menu>Hello World!</menu>
 
  <!-- Administration Main File Copy Section -->
  <files folder="admin">
   <filename>index.html</filename>
   <filename>admin.hello.php</filename>
  </files> 
 </administration>
</install>

你可能注意到了文件index.html,文件主要是浏览目录的时候显示这个文件,而不是显示目录下的文件结构。这个文件仅仅包含一行:

<html><body bgcolor="#FFFFFF"></body></html>

就是一个空白页面

 

另外一个文件是 admin.hello.php file,这是管理组件的入口,目前我们没有这部分内容,所以他的内容和index.html内容相同

转载于:https://www.cnblogs.com/vicenteforever/articles/1633004.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值