Создание базового компонента

Эта статья является частью курса «Разработка MVC-компонента под Джумла 1.6».


Создадим базовый компонент Hello World!.

Фронт-энд (публичная часть) править

Создайте файл yoursite/components/com_helloworld/helloworld.php следующего содержания:


Hello world


Протестируйте созданный компонент, введя index.php?option=com_helloworld в адресной строке браузера (не забудьте добавить путь к вашему сайту).

Бэк-энд (административная часть) править

Создайте файл yoursite/administrator/components/com_helloworld/helloworld.php следующего содержания:


Hello world administration


Протестируйте созданный компонент, введя administrator/index.php?option=com_helloworld в адресной строке браузера.

Создание установочного пакета править

Создайте каталог, содержащий следующие файлы:

admin/sql/updates/mysql/0.0.1.sql это пустой файл.

Создайте zip-архив из этого каталога и установите его, используя extension manager. Протестируйте созданный компонент, введя index.php?option=com_helloworld или administrator/index.php?option=com_helloworld в адресной строке браузера.

helloworld.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="1.6.0" method="upgrade">

	<name>Hello World!</name>
	<!-- Следующие элементы необязательны -->
	<creationDate>April 2011</creationDate>
	<author>John Doe</author>
	<authorEmail>john.doe@example.org</authorEmail>
	<authorUrl>http://www.example.org</authorUrl>
	<copyright>Copyright Info</copyright>
	<license>License Info</license>
	<!--  Версия компонента -->
	<version>0.0.1</version>
	<!-- Описание компонента (необязательный элемент, по умолчанию содержит название компонента)-->	
        <description>Description of the Hello World component ...</description>

	<update> <!-- Runs on update; New in 1.6 -->
		<schemas>
			<schemapath type="mysql">sql/updates/mysql</schemapath>
		</schemas>
	</update>

	<!-- Секция файлов фронт-энда (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>helloworld.php</filename>
	        </files>

	<administration>
		<!-- Administration Menu Section -->
		<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>

site/helloworld.php

Hello World

admin/helloworld.php

Hello World administration

index.html должен быть в каждом каталоге

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

Навигация править

Следующий урок: Добавление компонента на сайт.

Автор править

Разрешения править

При создании этой страницы использовались материалы страницы http://docs.joomla.org/Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01 согласно лицензии JEDL