J3.x

Developing a MVC Component/Introduction/fr

From Joomla! Documentation

< J3.x:Developing a MVC Component

J3.x:Developing a MVC Component/fr

Notes[edit]

This tutorial is adapted from Christophe Demko:

WARNING: this tutorial will not repeat the comments of Demko. To see them, please have a look to the original tutorial for Joomla! 2.5:

Exigences techniques[edit]

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. Please see also all the information about migration Upgrading Versions. Paramétrez "display_errors" sur 'On' pour faciliter le débogage des erreurs.

Migration de Joomla! 2.5 vers Joomla! 3.0[edit]

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)

Exemples : 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;

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

Nouveau MVC dans Joomla! 3.0[edit]

"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

Contributeurs[edit]