J3.x

Difference between revisions of "Developing an MVC Component/Adding a view to the site part/ru"

From Joomla! Documentation

< J3.x:Developing an MVC Component
(Created page with "Когда ни одна задача не подается в запрос переменным, то будет выполнена задача по умолчанию. Се...")
(Updating to match new version of source page)
 
(31 intermediate revisions by 3 users not shown)
Line 3: Line 3:
  
 
==Примечания==
 
==Примечания==
== Примечания ==!Н!Этот учебник является частью [[S:MyLanguage/J3.x:Developing_an_MVC_Component/Introduction|Developing в создание MVC компонента для Joomla! 3.х]]: Учебное пособие. Вам рекомендуется прочитать предыдущие части учебника перед прочтением этой.
+
* Этот учебник является частью [[S:MyLanguage/J3.x:Developing_an_MVC_Component/Introduction|Developing в создание MVC компонента для Joomla! 3.х]]: Учебное пособие. Вам рекомендуется прочитать предыдущие части учебника перед прочтением этой.
  
 
Вы можете следовать ниже, чтобы создать компонент Hello World!, или вы можете напрямую загрузить [https://github.com/scionescire/Joomla-3.2-Hello-World-Component/archive/step-1-basic-component.zip архив]
 
Вы можете следовать ниже, чтобы создать компонент Hello World!, или вы можете напрямую загрузить [https://github.com/scionescire/Joomla-3.2-Hello-World-Component/archive/step-1-basic-component.zip архив]
 +
 +
* As you follow through the steps of the tutorial you may find problems. In this case you may find it useful to read the Joomla page on [[S:MyLanguage/How_to_debug_your_code|How to debug your code]].
 +
 +
* You can watch a video associated with this step in the tutorial at [https://www.youtube.com/watch?v=HNYEHoAznJE Step 2, Adding a View].
 +
 +
{{#widget:YouTube|id=HNYEHoAznJE}}
  
 
==Добавление визуализации Hello World!==
 
==Добавление визуализации Hello World!==
Line 48: Line 54:
 
  | 6
 
  | 6
 
  | Создать: [[#site/views/helloworld/tml/default.php| default.php]]
 
  | Создать: [[#site/views/helloworld/tml/default.php| default.php]]
  | <tt><path_to_joomla>/components/com_helloworld/views/helloworld/tmpl/default.php</tt>
+
  | <tt><path_to_com_helloworld>/site/views/helloworld/tmpl/default.php</tt>
 
  |-
 
  |-
 
  | 7
 
  | 7
Line 61: Line 67:
 
=== Обновление Компонента Hello World! ===
 
=== Обновление Компонента Hello World! ===
 
Обновить Компонент Hello World! в Joomla! сайт, пожалуйста, выполните те же действия для [[S:MyLanguage/J3.x:Developing_an_MVC_Component/Developing_a_Basic_Component#Installing Hello World! Компонент |исходной установки]].
 
Обновить Компонент Hello World! в Joomla! сайт, пожалуйста, выполните те же действия для [[S:MyLanguage/J3.x:Developing_an_MVC_Component/Developing_a_Basic_Component#Installing Hello World! Компонент |исходной установки]].
 +
  
 
==Файл Детали==
 
==Файл Детали==
{{vanchor|site/helloworld.php}}
+
{{vanchor|site/helloworld.php}} (Note that some browsers may not copy and paste highlighted text correctly into a text editor. If you find this, then please try a different browser).
 
<source lang="php" highlight="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21">
 
<source lang="php" highlight="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21">
 
<?php
 
<?php
Line 70: Line 77:
 
  * @subpackage  com_helloworld
 
  * @subpackage  com_helloworld
 
  *
 
  *
  * @copyright  Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
+
  * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 
  * @license    GNU General Public License version 2 or later; see LICENSE.txt
 
  * @license    GNU General Public License version 2 or later; see LICENSE.txt
 
  */
 
  */
Line 95: Line 102:
 
  * @subpackage  com_helloworld
 
  * @subpackage  com_helloworld
 
  *
 
  *
  * @copyright  Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
+
  * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 
  * @license    GNU General Public License version 2 or later; see LICENSE.txt
 
  * @license    GNU General Public License version 2 or later; see LICENSE.txt
 
  */
 
  */
Line 117: Line 124:
 
  * @subpackage  com_helloworld
 
  * @subpackage  com_helloworld
 
  *
 
  *
  * @copyright  Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
+
  * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 
  * @license    GNU General Public License version 2 or later; see LICENSE.txt
 
  * @license    GNU General Public License version 2 or later; see LICENSE.txt
 
  */
 
  */
Line 157: Line 164:
 
  * @subpackage  com_helloworld
 
  * @subpackage  com_helloworld
 
  *
 
  *
  * @copyright  Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
+
  * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 
  * @license    GNU General Public License version 2 or later; see LICENSE.txt
 
  * @license    GNU General Public License version 2 or later; see LICENSE.txt
 
  */
 
  */
Line 176: Line 183:
 
<source lang="xml" highlight="13,30,31">
 
<source lang="xml" highlight="13,30,31">
 
<?xml version="1.0" encoding="utf-8"?>
 
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2.0" method="upgrade">
+
<extension type="component" version="3.0" method="upgrade">
  
 
<name>Hello World!</name>
 
<name>Hello World!</name>
 
<!-- The following elements are optional and free of formatting constraints -->
 
<!-- The following elements are optional and free of formatting constraints -->
<creationDate>December 2013</creationDate>
+
<creationDate>January 2018</creationDate>
 
<author>John Doe</author>
 
<author>John Doe</author>
 
<authorEmail>john.doe@example.org</authorEmail>
 
<authorEmail>john.doe@example.org</authorEmail>
Line 226: Line 233:
 
</extension>
 
</extension>
 
</source>
 
</source>
 +
  
 
== Код Пояснения ==
 
== Код Пояснения ==
Line 283: Line 291:
 
</source>
 
</source>
  
The view sets up the text to be output and then calls the base display class.
+
Представление задает текст для вывода и затем вызывает базовый класс дисплея.!Н!"[https://api.joomla.org/cms-3/classes/JViewLegacy.html JViewLegacy]" является базовым классом для Joomla! View. В нашем случае этот метод будет отображать данные с использованием tmpl/default.php файла.
''[https://api.joomla.org/cms-3/classes/JViewLegacy.html JViewLegacy]'' is a base class for a Joomla! View. In our case, this method will display data using the tmpl/default.php file.
+
 
 +
'''Caveat:''' If your view needs to load or otherwise embed individual JavaScript code, do not do that in the view, as the code might not get included when caching is enabled. Load those scripts in the controller instead. See
 +
[https://issues.joomla.org/tracker/joomla-cms/11203 the related issue on the issue tracker].
  
 
=== default.php ===
 
=== default.php ===
Line 292: Line 302:
 
</source>
 
</source>
  
This template file will be included by the JViewLegacy class. Therefore, here, $this refers to the HelloWorldViewHelloWorld class.
+
Этот файл шаблона будет включен в JViewLegacy класс. Поэтому, здесь переменная $this имеет ввиду HelloWorldViewHelloWorld класса.
  
 
=== helloworld.xml ===
 
=== helloworld.xml ===
Line 300: Line 310:
 
</source>
 
</source>
  
Updates the version number.
+
Обновляет номер версии.
  
 
<source lang="xml">
 
<source lang="xml">
Line 307: Line 317:
 
</source>
 
</source>
  
Tells installer application to add controller.php and the views/directory
+
Рассказывает установщик приложения добавить controller.php и мнения/каталог
  
==Component Contents==
+
==Содержание Компонента==
At this point in the tutorial, your component should contain the following files:
+
В этот момент ваш компонент должен содержать следующие файлы:
 
{| border=1
 
{| border=1
 
  | 1
 
  | 1
 
  | ''[[#helloworld.xml|helloworld.xml]]''
 
  | ''[[#helloworld.xml|helloworld.xml]]''
  | this is an XML (manifest) file that tells Joomla! how to install our component.
+
  | это XML-файл (манифест) файл, который говорит Joomla! как установить наш компонент.
 
  |-
 
  |-
 
  | 2
 
  | 2
 
  | ''[[#site/helloworld.php|site/helloworld.php]]''
 
  | ''[[#site/helloworld.php|site/helloworld.php]]''
  | this is the site entry point to the Hello World! component
+
  | это сайт точка входа для компонента Hello World!
 
  |-
 
  |-
 
  | 3
 
  | 3
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|site/index.html]]''
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|site/index.html]]''
  | prevents web server from listing directory content
+
  | предотвращает листинг из веб-сервера  содержимого директории
 
  |-
 
  |-
 
  | 4
 
  | 4
 
  | ''[[#site/controller.php|site/controller.php]]''
 
  | ''[[#site/controller.php|site/controller.php]]''
  | file representing the controller
+
  | файл, представляющий контроллер
 
  |-
 
  |-
 
  | 5
 
  | 5
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|site/views/index.html]]''
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|site/views/index.html]]''
  | prevents web server from listing directory content
+
  | предотвращает листинг из веб-сервера  содержимого директории
 
  |-
 
  |-
 
  | 6
 
  | 6
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|site/views/helloworld/index.html]]''
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|site/views/helloworld/index.html]]''
  | prevents web server from listing directory content
+
  | предотвращает листинг из веб-сервера  содержимого директории
 
  |-
 
  |-
 
  | 7
 
  | 7
 
  | ''[[#site/views/helloworld/view.html.php|site/views/helloworld/view.html.php]]''
 
  | ''[[#site/views/helloworld/view.html.php|site/views/helloworld/view.html.php]]''
  | file representing the view
+
  | файл определяющий вид
 
  |-
 
  |-
 
  | 8
 
  | 8
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|site/views/helloworld/tmpl/index.html]]''
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|site/views/helloworld/tmpl/index.html]]''
  | prevents web server from listing directory content
+
  | предотвращает листинг из веб-сервера  содержимого директории
 
  |-
 
  |-
 
  | 9
 
  | 9
 
  | ''[[#site/views/helloworld/tmpl/default.php|site/views/helloworld/tmpl/default.php]]''  
 
  | ''[[#site/views/helloworld/tmpl/default.php|site/views/helloworld/tmpl/default.php]]''  
  | the default view
+
  | представление по умолчанию
 
  |-
 
  |-
 
  | 10
 
  | 10
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|admin/index.html]]''
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|admin/index.html]]''
  | prevents web server from listing directory content
+
  | предотвращает листинг из веб-сервера  содержимого директории
 
  |-
 
  |-
 
  | 11
 
  | 11
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#admin/helloworld.php|admin/helloworld.php]]''
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#admin/helloworld.php|admin/helloworld.php]]''
  | this is the administrator entry point to the Hello World! component
+
  | это точка входа администратора в компонент Hello World!
 
  |-
 
  |-
 
  | 12
 
  | 12
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|admin/sql/index.html]]''
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|admin/sql/index.html]]''
  | prevents web server from listing directory content
+
  | предотвращает листинг из веб-сервера  содержимого директории
 
  |-
 
  |-
 
  | 13
 
  | 13
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|admin/sql/updates/index.html]]''
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|admin/sql/updates/index.html]]''
  | prevents web server from listing directory content
+
  | предотвращает листинг из веб-сервера  содержимого директории
 
  |-
 
  |-
 
  | 14
 
  | 14
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|admin/sql/updates/mysql/index.html]]''
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#index.html|admin/sql/updates/mysql/index.html]]''
  | prevents web server from listing directory content
+
  | предотвращает листинг из веб-сервера  содержимого директории
 
  |-
 
  |-
 
  | 15
 
  | 15
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#admin/sql/updates/mysql/0.0.1.sql|admin/sql/updates/mysql/0.0.1.sql]]''
 
  | ''[[S:MyLanguage/J3.2:Developing_an_MVC_Component/Developing_a_Basic_Component#admin/sql/updates/mysql/0.0.1.sql|admin/sql/updates/mysql/0.0.1.sql]]''
  | file allowing to initialise schema version of the com_helloworld component.
+
  | файл, позволяющий инициализировать версию схемы компонента com_helloworld.
 
  |}
 
  |}
  
{{notice|Please create a pull request or issue at https://github.com/joomla/Joomla-3.2-Hello-World-Component for any code descprepancies or if editing any of the source code on this page.}}
+
{{notice|Пожалуйста, задавайте вопросы в https://github.com/joomla/Joomla-3.2-Hello-World-Component для создания любого кода или редактируйте исходный код на этой странице.}}
  
 
<div class="row">  
 
<div class="row">  
<div class="large-6 columns">{{Basic button|S:MyLanguage/J3.x:Developing_an_MVC_Component/Developing_a_Basic_Component|Prev: Developing a Basic Component|class=expand success}}</div>
+
<div class="large-6 columns">{{Basic button|S:MyLanguage/J3.x:Developing_an_MVC_Component/Developing_a_Basic_Component|Prev: разработка базовых компонент|class=expand success}}</div>
<div class="large-6 columns">{{Basic button|S:MyLanguage/J3.x:Developing_an_MVC_Component/Adding_a_menu_type_to_the_site_part|Next: Adding a menu type to the site part|class=expand}}</div>
+
<div class="large-6 columns">{{Basic button|S:MyLanguage/J3.x:Developing_an_MVC_Component/Adding_a_view_to_the_site_part|Next: Добавление тем на сайт части|class=expand}}</div>
 
</div>
 
</div>
  

Latest revision as of 01:56, 22 January 2019

Other languages:
Deutsch • ‎English • ‎Nederlands • ‎español • ‎français • ‎português do Brasil • ‎русский • ‎العربية • ‎中文(台灣)‎

J3.x:Developing an MVC Component/ru

Примечания

Вы можете следовать ниже, чтобы создать компонент Hello World!, или вы можете напрямую загрузить архив

  • As you follow through the steps of the tutorial you may find problems. In this case you may find it useful to read the Joomla page on How to debug your code.

Добавление визуализации Hello World!

В данной статье мы рассмотрим, как добавить вид базового пакета Joomla! компонента. Для этого примера мы будем продолжать нашу работу на Hello World! компонент.

Существует несколько способов обновления для Joomla! компонент. В этом уроке мы сосредоточимся на варианте 2.

1 Вручную добавить файлы в <path_to_joomla>/
2 Обновление при помощи Joomla! Менеджер расширений и оригинальный каталог, несжатый, используемые для установки компонента
3 Обновление при помощи Joomla! Менеджер расширений и обновление сервера

Чтобы добавить представление вам нужно будет перейти к com_helloworld, что это оригинальный каталог мы сделали для нашего компонента. Используя ваш любимый файловый менеджер, создать или обновить следующие файлы; как создать или изменить файлы, добавить исходный код для каждого файла, который находится в подробности файла.

1 Обновление: helloworld.php <path_to_com_helloworld>/site/helloworld.php
2 Создать: controller.php <path_to_com_helloworld>/site/controller.php
3 Создать: index.html <path_to_com_helloworld>/site/views/index.html
4 Создать: index.html <path_to_com_helloworld>/site/views/helloworld/index.html
5 Создать: view.html.php <path_to_com_helloworld>/site/views/helloworld/view.html.php
6 Создать: default.php <path_to_com_helloworld>/site/views/helloworld/tmpl/default.php
7 Создать: index.html <path_to_com_helloworld>/site/views/helloworld/tmpl/index.html
8 Обновление: helloworld.xml <path_to_com_helloworld/helloworld.xml

Обновление Компонента Hello World!

Обновить Компонент Hello World! в Joomla! сайт, пожалуйста, выполните те же действия для исходной установки.


Файл Детали

site/helloworld.php (Note that some browsers may not copy and paste highlighted text correctly into a text editor. If you find this, then please try a different browser).

<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_helloworld
 *
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// Get an instance of the controller prefixed by HelloWorld
$controller = JControllerLegacy::getInstance('HelloWorld');

// Perform the Request task
$input = JFactory::getApplication()->input;
$controller->execute($input->getCmd('task'));

// Redirect if set by the controller
$controller->redirect();

site/controller.php

<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_helloworld
 *
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
 * Hello World Component Controller
 *
 * @since  0.0.1
 */
class HelloWorldController extends JControllerLegacy
{
}

site/views/helloworld/view.html.php

<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_helloworld
 *
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

/**
 * HTML View class for the HelloWorld Component
 *
 * @since  0.0.1
 */
class HelloWorldViewHelloWorld extends JViewLegacy
{
	/**
	 * Display the Hello World view
	 *
	 * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
	 *
	 * @return  void
	 */
	function display($tpl = null)
	{
		// Assign data to the view
		$this->msg = 'Hello World';

		// Display the view
		parent::display($tpl);
	}
}

site/views/helloworld/tmpl/default.php

<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_helloworld
 *
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
 
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
?>
<h1><?php echo $this->msg; ?></h1>

index.html Примечание - один и тот же код используется для всех папок

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

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.2</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>
		<filename>controller.php</filename>
		<folder>views</folder>
	</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>


Код Пояснения

В случае, если вам любопытно, почему это работает так, как он делает.

helloworld.php

defined('_JEXEC') or die('Restricted access');

Это позволяет для безопасной точки входа в интерфейс Joomla! Платформа. JEXEC содержится подробное объяснение.

$controller = JControllerLegacy::getInstance('HelloWorld');

"JControllerLegacy" является базовым классом для Joomla! Контроллер. Для того, чтобы наш сайт использовал контроллеры, мы должны расширить этот класс в нашем компоненте. В "getInstance" статический метод "JControllerLegacy" класса создадим контроллер. В коде, приведенном выше, это будет инстанцировать объект класса контроллера по имени "HelloWorldController". Joomla будет искать объявление этого класса в <path_to_joomla>/htdocs/components/com_helloworld/controller.php.

$input = JFactory::getApplication()->input;
$controller->execute($input->getCmd('task'));

После того, как контроллер создан, мы инструктируем контроллер для выполнения задачи, как определено в URL: <yoursite>/joomla/index.php?option=com_helloworld&task=<task_name>. Если задача поставлена, задача по умолчанию 'display' будет принято. Когда дисплей не используется, 'view' переменная будет решать, что будет отображаться. Другими распространенными задачами являются save, edit, new и т. д.

$controller->redirect();

Контроллер может принять решение перенаправить страницу, обычно после того, как задание 'save' было завершено. Это последнее заявление заботится о фактическом перенаправлении.

Основные точки входа, helloworld.php, по сути, передает управление контроллеру, который обрабатывает задачу, которая была указана в запросе. Наш компонент конкретного контроллера больше ничего не делает, чем то, что делает родительский класс, потому наш класс контроллера пуст.

controller.php

class HelloWorldController extends JControllerLegacy
{
}

Когда ни одна задача не подается в запрос переменным, то будет выполнена задача по умолчанию. Сейчас это задача отображения по умолчанию. В JControllerLegacy классе есть такая задача. В нашем примере она будет показывать надпись с именем helloworld.

view.html.php

class HelloWorldViewHelloWorld extends JViewLegacy
{
	function display($tpl = null)
	{
		// Assign data to the view
		$this->msg = 'Hello World';
 
		// Display the view
		parent::display($tpl);
	}
}

Представление задает текст для вывода и затем вызывает базовый класс дисплея.!Н!"JViewLegacy" является базовым классом для Joomla! View. В нашем случае этот метод будет отображать данные с использованием tmpl/default.php файла.

Caveat: If your view needs to load or otherwise embed individual JavaScript code, do not do that in the view, as the code might not get included when caching is enabled. Load those scripts in the controller instead. See the related issue on the issue tracker.

default.php

<h1><?php echo $this->msg; ?></h1>

Этот файл шаблона будет включен в JViewLegacy класс. Поэтому, здесь переменная $this имеет ввиду HelloWorldViewHelloWorld класса.

helloworld.xml

<version>0.0.2</version>

Обновляет номер версии.

<filename>controller.php</filename>
<folder>views</folder>

Рассказывает установщик приложения добавить controller.php и мнения/каталог

Содержание Компонента

В этот момент ваш компонент должен содержать следующие файлы:

1 helloworld.xml это XML-файл (манифест) файл, который говорит Joomla! как установить наш компонент.
2 site/helloworld.php это сайт точка входа для компонента Hello World!
3 site/index.html предотвращает листинг из веб-сервера содержимого директории
4 site/controller.php файл, представляющий контроллер
5 site/views/index.html предотвращает листинг из веб-сервера содержимого директории
6 site/views/helloworld/index.html предотвращает листинг из веб-сервера содержимого директории
7 site/views/helloworld/view.html.php файл определяющий вид
8 site/views/helloworld/tmpl/index.html предотвращает листинг из веб-сервера содержимого директории
9 site/views/helloworld/tmpl/default.php представление по умолчанию
10 admin/index.html предотвращает листинг из веб-сервера содержимого директории
11 admin/helloworld.php это точка входа администратора в компонент Hello World!
12 admin/sql/index.html предотвращает листинг из веб-сервера содержимого директории
13 admin/sql/updates/index.html предотвращает листинг из веб-сервера содержимого директории
14 admin/sql/updates/mysql/index.html предотвращает листинг из веб-сервера содержимого директории
15 admin/sql/updates/mysql/0.0.1.sql файл, позволяющий инициализировать версию схемы компонента com_helloworld.
Info non-talk.png
General Information

Пожалуйста, задавайте вопросы в https://github.com/joomla/Joomla-3.2-Hello-World-Component для создания любого кода или редактируйте исходный код на этой странице.