教程栏目

joomla中文网出品的官方教程

在Joomla框架中,组件是通过点击菜单项运行的。 现在我们创建菜单项的时候还不会有 HelloWorld 这个选项,加上这个功能很简单:加一个 site/views/helloworld/tmpl/default.xml 文件内容如下:

 

site/views/helloworld/tmpl/default.xml

<?xml version="1.0" encoding="utf-8"?>
<metadata>
 <layout title="COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_TITLE">
  <message>COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_DESC</message>
 </layout>
</metadata>

大家看到上述代码中诸如"COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_TITLE"的内容比较古怪,当然如果您看过joomla的代码,就会发现,到处都是这样的字符串,也会明白这是为了适用多语言环境的策略。当然现在还不能翻译过来,后面的教程我们将搞定这个事情。

修改 helloworld.xml 发布0.0.3这个版本:

helloworld.xml

<extension type="component" version="2.5.0" method="upgrade">
 
 <name>Hello World!</name>
 <!-- The following elements are optional and free of formatting constraints -->
 <creationDate>November 2009</creationDate>
 <author>John Doe</author>
 <authorEmail>这个 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>0.0.3</version><!—注意到没?这里发生变化了-->
 <!-- The description is optional and defaults to the name -->
 <description>Description of the Hello World component ...</description>
 
 <update> <!—升级时运行的数据库操作文件这是2.5版本后的新功能 -->
  <schemas>
   <schemapath type="mysql">sql/updates/mysql</schemapath>
  </schemas>
 </update> 
 <!—前台文件 -->
 <!—文件夹被表明为site,表示这个文件夹下的文件将被拷贝到网站根目录,因为是升级只需要包含修改的文件就够了。还记得吗?2.5版本以前要把用到各个层次的文件都要列举出来,现在只需要把文件夹包含就行了! -->
 <files folder="site">
  <filename>index.html</filename>
  <filename>helloworld.php</filename>
  <filename>controller.php</filename>
  <folder>views</folder>
 </files> 
 <administration>
  <!—被Administration段括起来的是用于后台管理的文件 -->
  <menu>Hello World!</menu>
  <!-- Administration 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 /admin/ in the package -->
  <files folder="admin">
   <!-- Admin Main File Copy Section -->
   <filename>index.html</filename>
   <filename>helloworld.php</filename>
   <!-- SQL files section -->
   <folder>sql</folder>
  </files>
 </administration> 
</extension>
转载自星仔码头

评论 (0)

  • 最新在前
  • 最佳在前

第1章 经验分享

第2章 专题教程

第3章 扩展推荐

第13章 扩展更新日志