教程栏目

joomla中文网出品的官方教程

本节将以zmax_removeScript插件为例来说明如何给自己的插件增加自动检查更新功能。

前期工作:

1,在扩展的XML文件中增加<updateservers>字段

2,开发一个新的zmax_removescript扩展设置新的版本号

3,在服务器上放在一个更新用到的XML文件。


XML文件设置updateservers字段:

<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="system" method="upgrade">
	<name>plg_system_removescript</name>
	<author>min.zhang</author>
	<creationDate>2014-07-11</creationDate>
	<copyright>(C) 2014 - 2018 . All rights reserved.</copyright>
	<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
	<authorEmail>zhang19min88AT163.com</authorEmail>
	<authorUrl>www.zmax99.com</authorUrl>
	<version>2.5.0</version>
	<description>PLG_REMOVESCRIPT_DESCRIPTION</description>
	
	<files>
		<filename plugin="removescript">removescript.php</filename>
		<filename>index.html</filename>
	</files>

	<config>
		<fields name="params">
			<fieldset name="basic">
				<field  name="remove_script" 
				        type="input"
						description="PLG_REMOVESCRIPT_FIELD_REMOVE_SCRIPT_DESC"
						label="PLG_REMOVESCRIPT_FIELD_REMOVESCRIPT_LABEL"
						default="google"
						/>
				<field name="local_script"
						type="input"
						description="PLG_REMOVESCRIPT_FIELD_LOCAL_SCRIPT_DESC"
						label="PLG_REMOVESCRIPT_FIELD_LOCAL_SCRIPT_LABEL"
						default=""
						/>
			</fieldset>
			
			<fieldset name="advanced">
				<field name="blog"
						type="list"
						description="PLG_REMOVESCRIPT_FIELD_LOG_DESC"
						label="PLG_REMOVESCRIPT_FIELD_LOG_LABEL"
						default="0"
						>
						<option value="1">PLG_REMOVESCRIPT_FIELD_LOG_ENABLE</option>
						<option value="0">PLG_REMOVESCRIPT_FIELD_LOG_DISABLE</option>
				</field>
			</fieldset>
		</fields>
	</config>
	<updateservers>
		<server type="extension" priority="1" name="ZMAX RemoveScript Auto Update">http://www.zmax99.com/autoupdate/auto-update-removescript.xml</server>
	</updateservers>
</extension>

 重点在于updateservers和version这两个字段。updateserver指定更新文件的地址为:http://www.zmax99.com/autoupdate/auto-update-removescript.xml,version指定了当前程序的版本为2.5.0。

服务器上的auto-update-removescript.xml文件

<?xml version="1.0" encoding="utf-8"?>

<updates>

   <update>

      <name>System - RemoveScript</name>

      <description>ZMAX程序人开发的RemoveScript扩展有新的版本了!</description>

      <element>removescript</element>

      <type>plugin</type>

      <folder>system</folder>

      <client>0</client>

      <client_id>0</client_id>

      <version>2.5.6</version> 

      <infourl title="ZMAX程序人 URL">http://www.zmax99.com</infourl>

      <downloads>

         <downloadurl type="full" format="zip">http://localhost/test/autoupdate/j25/plg_removescript_v2.5.6.zip</downloadurl>

      </downloads>

      <tags>

         <tag>stable</tag>

      </tags> 

      <maintainer>ZMAX程序人</maintainer>

      <maintainerurl>http://www.zmax99.com</maintainerurl>

      <targetplatform name="joomla" version="2.5" />

   </update> 

  

</updates>

 上面指明了现在可供更新的版本为2.5.6.你可以在<info>字段中指定一个更新特性描述页。上例为www.zmax99.com.在downloadurl中指定安装包的位置。

完成了这3项,就实现了自动检查更新的功能了。

 



 

作者: 樱木花道

Joomla程序员,从J1.5到J4.x始终都在做Joomla相关开发定制工作,有超过10年行业经验,国内Joomla扩展开发商ZMAX团队的核心成员

作者网站:ZMAX程序人

评论 (0)

  • 最新在前
  • 最佳在前

第1章 Joomla入门教程

第3章 C计划

第5章 E计划

第6章 H计划

第7章 G计划

第9章 运行环境

第11章 主从与集群

第12章 模块开发

第13章 插件开发

第14章 j2.x组件开发教程

第15章 页面定制教程

第16章 页面构造器

第17章 joomla升级