Actions

J3.x

Difference between revisions of "Developing a MVC Component/Introduction"

From Joomla! Documentation

< J3.x:Developing a MVC Component
m (Minor typos fixed)
 
(30 intermediate revisions by 5 users not shown)
Line 1: Line 1:
This tutorial is adapted from Christophe Demko - [http://docs.joomla.org/User:Cdemko]:
+
{{:J3.1:Developing a MVC Component}}
Developing a Model-View-Controller Component/2.5
+
  
WARNING: this tutorial will not repeat the comments Demko, to see them see your tutorial:
+
==Notes==
[http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Introduction]
+
This tutorial is adapted from [[User:Cdemko|Christophe Demko]]:  
 +
*[[Developing a Model-View-Controller Component/2.5]]
  
This is my first sample component to Joomla 3.0.
+
WARNING: this tutorial will not repeat the comments of Demko. To see them, read his tutorial:
 +
*[[Developing_a_Model-View-Controller_Component/2.5/Introduction|2.5 - Introduction]]
 +
 
 +
Here is the part 17:
 +
*[[Developing_a_Model-View-Controller_Component/2.5/Adding_an_update_server|2.5 - Adding_an_update_server]] migrated to Joomla! 3.1 and your final zip.
 +
 
 +
This is my first sample component to Joomla! 3.1.
 +
 
 +
== My contributions: ==
 +
* Migration to Joomla! 3.1
 +
* Add language pt-BR
  
 
----
 
----
 
== Requirements ==
 
== Requirements ==
You need Joomla! 3.0 Beta1 (with PHP, MySQL, Apache and Microsoft II) or greater for this tutorial.
+
You need Joomla! 3.0 (with PHP, MySQL and Apache/Microsoft IIS) or greater for this tutorial.
  
== Introduction ==
+
I gathered a lot of information and then I started to migrate the component of the new Joomla! 2.5 to 3.0.
I gathered a lot of information and then I started to migrate the component of the new Joomla 2.5 to 3.0 (still in beta1).
+
 
Below is some important information used for migration:
 
Below is some important information used for migration:
  
Use "display_errors On" to help in errors debug.
+
Use "display_errors On" to help with debugging errors.
  
== Migrating Joomla 2.5 to Joomla 3.0: ==
+
== Migrating Joomla! 2.5 to Joomla! 3.0: ==
  
Remember that you need to add Legacy any place you are directly extending JModel, JView or JController.  If it is indirect (like through JModellist) you don't have to, it's already taken care of.
+
Remember that you need to add Legacy at any place where you are directly extending JModel, JView or JController.  If it is indirect (like through JModelList) you don't have to, it's already taken care of.
Other than that and the fact that as announced long ago deprecated code has been removed (I'd guess that JParameter is the biggest impact )   extensions should only need minor changes ... although you will want to look at the output changes that Kyle is working on.
+
Other than that and the fact that, as announced long ago, deprecated code has been removed (I'd guess that JParameter is the biggest impact), extensions should only need minor changes ... Although you will want to look at the output changes that Kyle is working on.
Of course if you are building stand alone platform applications the new MVC and jApplicationWeb/JApplicationCLI are completely the way you should work and the nice thing about the way we have done this is that the new packages are already right there on your server having arrived with the CMS.
+
Of course, if you are building standalone platform applications, the new MVC and JApplicationWeb/JApplicationCLI are completely the way you should work and the nice thing about the way we have done this is that the new packages are already right there on your server having arrived with the CMS.
 
(Elin in development list)
 
(Elin in development list)
  
Line 35: Line 44:
 
define('DS',DIRECTORY_SEPARATOR);
 
define('DS',DIRECTORY_SEPARATOR);
 
}
 
}
</source>
 
  
 
//$controller = JController::getInstance('HelloWorld');
 
//$controller = JController::getInstance('HelloWorld');
 
 
$controller = JControllerLegacy::getInstance('HelloWorld');
 
$controller = JControllerLegacy::getInstance('HelloWorld');
 
  
 
//class HelloWorldViewHelloWorlds extends JView
 
//class HelloWorldViewHelloWorlds extends JView
 
 
class HelloWorldViewHelloWorlds extends JViewLegacy
 
class HelloWorldViewHelloWorlds extends JViewLegacy
 
  
 
class HelloWorldController extends JControllerLegacy
 
class HelloWorldController extends JControllerLegacy
 
  
 
class HelloWorldModelHelloWorld extends JModelItemLegacy
 
class HelloWorldModelHelloWorld extends JModelItemLegacy
 
  
 
class HelloWorldModelUpdHelloWorld extends JModelFormLegacy
 
class HelloWorldModelUpdHelloWorld extends JModelFormLegacy
 
  
 
JRegistry::getValue() now is JRegistry::get()
 
JRegistry::getValue() now is JRegistry::get()
  
 
+
//Convert sample to JRegistry with LoadJSON - Sample from Joomla! 3.0 sourcecode
//Convert sample to JRegistry with LoadJSON - Sample from Joomla 3.0 sourcecode
+
 
+
  
 
// $params = new JRegistry;
 
// $params = new JRegistry;
 
 
// $params->loadJSON($this->item->params);
 
// $params->loadJSON($this->item->params);
 
 
// $this->item->params = $params;
 
// $this->item->params = $params;
 
  
 
$params = new JRegistry;
 
$params = new JRegistry;
 
 
$params->loadString($item->params);
 
$params->loadString($item->params);
 
 
$item->params = $params;
 
$item->params = $params;
 +
</source>
 +
 +
Here source code:
 +
http://joomlacode.org/gf/project/hellojoomla3/frs/
 +
 +
== New MVC in Joomla! 3.0 ==
  
== Starting: ==
+
"Version 12.1 of the platform introduced a new format for the model-view-controller paradigm. In principle, the classes JModel, JView and JController are now interfaces and the base abstract classes are now JModelBase, JViewBase and JControllerBase, respectively. In addition, all classes have been simplified, removing a lot of coupling with the Joomla! CMS, that was unnecessary for standalone Joomla! Platform applications." ...
{{:Developing a Model-View-Controller Component/3.0}}
+
[http://developer.joomla.org/manual/chap-Joomla_Platform_Manual-MVC.html Joomla! Platform Manual MVC]
  
 +
{{:J3.2:Developing a MVC Component/Navigate
 +
|prev=Introduction <!-- previous article subpage name -->
 +
|next=Developing a Basic Component <!-- next article subpage name -->}}
 
== Contributors ==
 
== Contributors ==
*[[User:cdemko|Christophe Demko]]
+
* User:ribafs - Ribamar FS - [http://docs.joomla.org/Special:Contributions/Ribafs]
* User:ribafs - Ribamar FS - [http://docs.joomla.org/User:Ribafs]
+
  
[[Category:Development]]
+
<noinclude>[[Category:Development]] [[Category:Joomla! 3.0]] [[Category:Joomla! 3.1]]</noinclude>
[[Category:Joomla! 1.6]]
+
[[Category:Joomla! 1.7]]
+
[[Category:Joomla! 2.5]]
+
[[Category:Manual]]
+

Latest revision as of 12:43, 8 June 2014


This is a multiple-article series of tutorials on how to develop a Model-View-Controller Component for Joomla! Version Joomla 3.x.

Begin with the Introduction, and navigate the articles in this series by using the navigation box to the right (the Articles in this series).

Notes

This tutorial is adapted from Christophe Demko:

WARNING: this tutorial will not repeat the comments of Demko. To see them, read his tutorial:

Here is the part 17:

This is my first sample component to Joomla! 3.1.

My contributions:

  • Migration to Joomla! 3.1
  • Add language pt-BR

Requirements

You need Joomla! 3.0 (with PHP, MySQL and Apache/Microsoft IIS) or greater for this tutorial.

I gathered a lot of information and then I started to migrate the component of the new Joomla! 2.5 to 3.0. Below is some important information used for migration:

Use "display_errors On" to help with debugging errors.

Migrating Joomla! 2.5 to Joomla! 3.0:

Remember that you need to add Legacy at any place where you are directly extending JModel, JView or JController. If it is indirect (like through JModelList) you don't have to, it's already taken care of. Other than that and the fact that, as announced long ago, deprecated code has been removed (I'd guess that JParameter is the biggest impact), extensions should only need minor changes ... Although you will want to look at the output changes that Kyle is working on. Of course, if you are building standalone platform applications, the new MVC and JApplicationWeb/JApplicationCLI are completely the way you should work and the nice thing about the way we have done this is that the new packages are already right there on your server having arrived with the CMS. (Elin in development list)

Samples:

DS

Since we've removed the DS constant in 3.0, we need to replace the uses of the constant in com_media. The most unobtrusive change is to simply replace it with PHP's DIRECTORY_SEPARATOR constant since DS is an alias to that.

(joomlacode)

if(!defined('DS')){
define('DS',DIRECTORY_SEPARATOR);
}
 
//$controller = JController::getInstance('HelloWorld');
$controller = JControllerLegacy::getInstance('HelloWorld');
 
//class HelloWorldViewHelloWorlds extends JView
class HelloWorldViewHelloWorlds extends JViewLegacy
 
class HelloWorldController extends JControllerLegacy
 
class HelloWorldModelHelloWorld extends JModelItemLegacy
 
class HelloWorldModelUpdHelloWorld extends JModelFormLegacy
 
JRegistry::getValue() now is JRegistry::get()
 
//Convert sample to JRegistry with LoadJSON - Sample from Joomla! 3.0 sourcecode
 
//                              $params = new JRegistry;
//                              $params->loadJSON($this->item->params);
//                              $this->item->params = $params;
 
                                $params = new JRegistry;
                                $params->loadString($item->params);
                                $item->params = $params;

Here source code: http://joomlacode.org/gf/project/hellojoomla3/frs/

New MVC in Joomla! 3.0

"Version 12.1 of the platform introduced a new format for the model-view-controller paradigm. In principle, the classes JModel, JView and JController are now interfaces and the base abstract classes are now JModelBase, JViewBase and JControllerBase, respectively. In addition, all classes have been simplified, removing a lot of coupling with the Joomla! CMS, that was unnecessary for standalone Joomla! Platform applications." ... Joomla! Platform Manual MVC


Tutorial Navigation

Prev: Introduction


Contributors

  • User:ribafs - Ribamar FS - [1]