J3.x

Entwicklung der Basis Komponente

From Joomla! Documentation

< J3.x:Developing an MVC Component
This page is a translated version of the page J3.x:Developing an MVC Component/Developing a Basic Component and the translation is 16% complete.

Outdated translations are marked like this.
Other languages:
العربية • ‎Deutsch • ‎English • ‎español • ‎français • ‎Nederlands • ‎português do Brasil • ‎русский • ‎中文(中国大陆)‎
Joomla! 
3.x
Tutorial
Entwicklung einer MVC Komponente


Dies ist eine Artikel-Serie mit Tutorials über die Entwicklung einer Model-View-Controller Komponente für Joomla! VersionJoomla 3.x.

Beginne mit der Einführung und navigiere durch die Artikel dieser Serie mit Hilfe des Buttons am Ende der Seite oder der Box auf der rechten Seite ("Artikel in dieser Serie").



Info

Dieses Tutorial ist ein Teil der Entwicklung einer MVC Komponente für Joomla! 3.x Artikel-Serie. Es ist sinnvoll die vorherigen Teile des Tutorials zu lesen bevor du hier fortfährst.

If you have used Joomla! before reading this tutorial, you have noticed that extensions are installed using a compressed file containing all the things which are needed for installing and uninstalling them.

Wenn du die nachfolgenden Schritte durcharbeitest, kannst du selbst deine eigene Hello World! Komponente erstellen. Du kannst das Archiv aber auch hier direkt herunterladen.

Here are some slides based on this documents to explain how to create basic to advance Joomla! components.
Joomla! Basic Component Help
Joomla! Advance Component Help

There are also a number of videos which accompany steps in the tutorial, beginning with
Step 1, Developing a Basic Component and you can access the slides which are used in the series of video presentations at Slides.

Important! Around version 3.8 the Joomla developers started changing the naming of Joomla classes and where they were stored in the directory structure. Many of the tutorial steps and videos refer to the old naming convention. To find the equivalent new class and where it's stored, look in your libraries/classmap.php file.

Wie du eine eigene Komponente zu Joomla! hinzufügst

In diesem Artikel zeigen wir dir wie du eine Basis-Komponente für Joomla! erstellst und anschließend installierst. Für dieses Beispiel werden wir mit der Hello World! Komponente arbeiten.

Zu Beginn erstelle bitte mit deinem bevorzugten Datei-Explorer einen Ordner für die Hello World! Komponente. Dieser Ordner kann überall auf deinem Dateisystem sein, er muss nur außerhalb deines Joomla! Installationsverzeichnisses sein. Für dieses Beispiel geben wir dem neuen Ordner den Namen com_helloworld, aber grundsätzlich kann der Ordner auch jeden beliebigen anderen Namen besitzen.

Als nächstes müssen wir innerhalb des gerade erstellten Verzeichnisses einige Dateien anlegen. Lege die folgenden Dateien an und schreibe den jeweiligen Source-Code für jede Datei. Den jeweiligen Code findest du hier File Details.

1 helloworld.xml this is an XML (manifest) file that tells Joomla! how to install our component.
2 site/helloworld.php this is the site entry point to the Hello World! component
3 site/index.html prevents web server from listing directory content
4 admin/index.html prevents web server from listing directory content
5 admin/helloworld.php this is the administrator entry point to the Hello World! component
6 admin/sql/index.html prevents web server from listing directory content
7 admin/sql/updates/index.html prevents web server from listing directory content
8 admin/sql/updates/mysql/index.html prevents web server from listing directory content
9 admin/sql/updates/mysql/0.0.1.sql file allowing to initialise schema version of the com_helloworld component.

Installation der Hello World! Komponente

Erstelle mit deinem bevorzugten Datei-Explorer ein Zip-Archiv aus diesem Verzeichnis. Für dieses Beispiel nennen wir die Datei com_helloworld.zip. Und wieder der Hinweis der Name dieser Datei kann beliebig gewählt werden.

Now we need to install the Hello World! component. There are two ways to do this, both are covered in Installing an Extension. Here we will cover the method using the Extension Manager of Joomla!.

  • Using your preferred web browser, navigate to the Administrator panel of your Joomla! site. The address would be <yoursite>/joomla/administrator/index.php. For this example we will navigate to localhost/joomla/administrator/index.php.
  • Click Extensions    Manage    Install    Upload Package File    Choose File
  • Navigate and Select File
  • Click Upload & Install

Note - You should see a message letting you know if the installation succeeded or failed.

You can test this basic function of the component by entering the Hello World! page for the site and administrator portions of your Joomla! website.

  • Using your preferred web browser, navigate to the Hello World! component page located on the site portion of your website. The address would be <yoursite>/joomla/index.php?option=com_helloworld. For this example we will navigate to localhost/joomla/index.php?option=com_helloworld.
  • Using your preferred web browser, navigate to the Hello World! component page located on the administrator portion of your website. The address would be <yoursite>/joomla/administrator/index.php?option=com_helloworld. For this example we will navigate to localhost/joomla/administrator/index.php?option=com_helloworld.

You can also notice that the Hello World! component is visible in the administrator site of your Joomla installation under the Components menu.

File Details

admin/sql/updates/mysql/0.0.1.sql is an empty file allowing to initialise schema version of the com_helloworld component.

helloworld.xml

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

	<name>Hello World!</name>
	<!-- The following elements are optional and free of formatting constraints -->
	<creationDate>January 2018</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>
	<!--  The version string is recorded in the components table -->
	<version>0.0.1</version>
	<!-- The description is optional and defaults to the name -->
	<description>Description of the Hello World component ...</description>

	<update> <!-- Runs on update; New since J2.5 -->
		<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 link='index.php?option=com_helloworld'>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

common to all folders

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


Component Contents

At this point in the tutorial, your component should contain the following files:

1 helloworld.xml this is an XML (manifest) file that tells Joomla! how to install our component.
2 site/helloworld.php this is the site entry point to the Hello World! component
3 site/index.html prevents web server from listing directory content
4 admin/index.html prevents web server from listing directory content
5 admin/helloworld.php this is the administrator entry point to the Hello World! component
6 admin/sql/index.html prevents web server from listing directory content
7 admin/sql/updates/index.html prevents web server from listing directory content
8 admin/sql/updates/mysql/index.html prevents web server from listing directory content
9 admin/sql/updates/mysql/0.0.1.sql file allowing to initialise schema version of the com_helloworld component.
Info non-talk.png
General Information

An updated git repository following along this tutorial is available @ https://github.com/Stevec4/Joomla-HelloWorld for any code descprepancies or edits please make a pull request.