Joomla2.5 Component 組件開發入門之HelloWorld 詳解!

來源:互聯網
上載者:User

一  初級HelloWorld

組建是放在components目錄下面的。

1、我們可以在Joomla根目錄下直接建立一個目錄com_helloworld

注意:組建目錄都是以com_開頭的。

2、在com_helloworld目錄下建立 helloworld.php  

注意:命名要和目錄名一致!

helloworld.php 內容:

hello world


測試:

http://localhost/index.php?option=com_helloworld


這個錯誤是正常的,因為我們沒有安裝正規的方法來。

繼續看下面

二、helloworld之完善

用正規的方法,來開發一個可安裝的組件,ZIP壓縮檔!

重新在外面另建一個檔案夾com_helloworld

在此檔案夾下建立:

site/helloworld.php  (前台)

site/index.html (前台)

admin/helloworld.php (後台)

admin/index.html (後台)

hellowold.xml (安裝該組件的一些配置資訊)

下面來介紹各檔案的內容:

site/helloworld.php

Hello world

admin/helloworld.php:

Hello World Administrator

hellowold.xml

<?xml version="1.0" encoding="utf-8"?><install type="component" version="2.5"><name>helloworld</name><creationDate>2011-11-09</creationDate><author>gao tong</author><copyright>Copyright Info</copyright><license>License Info</license><version>1.01</version><description>Hello World Test Component ...</description><files folder="site"><filename>index.html</filename><filename>helloworld.php</filename></files><administration><menu img="components/com_proforms/images/love.png" >COM_HelloWorld</menu><files folder="admin"><filename>index.html</filename><filename>helloworld.php</filename></files></administration></install>

上面的配置比較的重要的就是 指定所有的檔案,要正確!

<administration>必須要有,組件的安裝是前台和後台都要有的


index.html

可以留空!或:

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


最後:打包成ZIP,已經可以安裝了。

在後台安裝該組件。後台組件裡面就可以看到這個組件了。

開啟之後:


前台測試:http://localhost/administrator/index.php?option=com_helloworld



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.