J3.x

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

From Joomla! Documentation

< J3.x:Developing an MVC Component
Line 68: Line 68:
 
</source>
 
</source>
  
* == Source code from a Model-View-Controller Component to Joomla 3.0 ==
+
== Source code from a Model-View-Controller Component to Joomla 3.0 ==
 
Download - [http://ribafs.org/sites/cursodephp/down/joomla/com_ola_j3.zip]
 
Download - [http://ribafs.org/sites/cursodephp/down/joomla/com_ola_j3.zip]
  

Revision as of 06:39, 25 September 2012

This tutorial is adapted from Christophe Demko - [1]: Developing a Model-View-Controller Component/2.5

WARNING: this tutorial will not repeat the comments Demko, to see them see your tutorial: [2]

Here only the part 17, this: [3] migrated to Joomla 3.0 and your final zip.

This is my first sample component to Joomla 3.0.

My contributions:[edit]

  • Migration to Joomla 3.0
  • Add language pt-BR

Requirements[edit]

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

Introduction[edit]

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:

Use "display_errors On" to help in errors debug.

Migrating Joomla 2.5 to Joomla 3.0:[edit]

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. 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. (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;

Source code from a Model-View-Controller Component to Joomla 3.0[edit]

Download - [4]

Contributors[edit]