The new MVC paradigm in Joomla 3.0

2,988 views
Skip to first unread message

Cliff Ford

unread,
Sep 29, 2012, 9:19:07 AM9/29/12
to joomla-de...@googlegroups.com
I was thinking of starting a new Extension from scratch with the new J3
MVC paradigm. I noticed that all of the components in Joomla! 3.0.0 use
the 'Legacy' versions of JController, JModel and JView and I can't find
a single example of a component produced with the new paradigm. All I
have to go on is Chapter 2.7 of the Platform Manual. Am I missing
something? I don't feel sufficiently confident to strike out alone into
new territory.

Cliff

elin

unread,
Sep 30, 2012, 6:12:03 AM9/30/12
to joomla-de...@googlegroups.com
There are a number of applications (not components but stand alone) that use the new mvc that are good for reference. Stefan's is a good one:



Elin

Soheil Novinfard

unread,
Sep 30, 2012, 8:23:46 AM9/30/12
to joomla-de...@googlegroups.com
Is there any new paradigm for MVC in Joomla 3.0? I can't see anything changed ...

Cliff Ford

unread,
Sep 30, 2012, 11:30:42 AM9/30/12
to joomla-de...@googlegroups.com
I am not sure I should be the one to answer this ("I can't see anything
changed"). But...

If you compare the directory structures of Joomla 2.5 and 3.0
installations you will see that in the latter the 'libraries' directory
has a 'legacy' directory that contains all of the stuff that was in the
joomla directory of the former with the addition of 'controller',
'model' and 'view' directories. The version 3.0 joomla directory content
is different. Also, the manual says this:

Version 12.1 of the platform introduced a new format for
model-view-controller paradigm.

See: http://developer.joomla.org/manual/chap-Joomla_Platform_Manual-MVC.html

I was just looking for some clue on how best to write new code without
using Legacy classes, which will presumably disappear at some point.
Some sort of example component by an expert familiar with the new class
structure would be very welcome.

Cliff

On 30/09/12 13:23, Soheil Novinfard wrote:
> Is there any new paradigm for MVC in Joomla 3.0? I can't see anything
> changed ... --
> You received this message because you are subscribed to the Google
> Groups "Joomla! General Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-general/-/QFbC1dBKtesJ.
> To post to this group, send an email to
> joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-gene...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Message has been deleted

Nils Rückmann

unread,
Sep 30, 2012, 7:37:35 PM9/30/12
to joomla-de...@googlegroups.com
I may be wrong, but should we not think about how to adobt the new mvc-structure for components by creating a solid base first ? Or is there any progress i haven't mentioned for basic form-, list- or item-classes ? 

elin

unread,
Oct 1, 2012, 7:58:20 PM10/1/12
to joomla-de...@googlegroups.com
There is a new MVC structure in the Joomla Platform. The Joomla Platform ships as part of the Joomla CMS. The Joomla  CMS does not use it but you can among other things write applications using it that would work right next to the CMS without a single change needed.  You could even write an extension to the CMS that uses it if you want but it would require some work for the backend especially. Yannick wrote a cool hello world that was new MVC in the front and old MVC in the back since in the back especially jmodellist etc are so handy.

Elin

So does Joomla have a new MVC?  Yes and no depending what you mean. 

Nils Rückmann

unread,
Oct 2, 2012, 8:02:30 AM10/2/12
to joomla-de...@googlegroups.com
@Elin: Is there any work or idea in progress for adopting the MVC to our core extensions or even for implementing cms-related basic classes ?

Herman Peeren

unread,
Oct 2, 2012, 9:46:00 AM10/2/12
to joomla-de...@googlegroups.com
On Tuesday, 2 October 2012 14:02:30 UTC+2, Nils Rückmann wrote:
@Elin: Is there any work or idea in progress for adopting the MVC to our core extensions or even for implementing cms-related basic classes ?

AFAIK, the idea was that the new MVC classes will be used in the CMS when the Unified Content Model (UCM) is ready. See: https://groups.google.com/forum/#!msg/joomla-dev-platform/sqdZ0B_WCiQ/uuglzpSbf3QJ and http://www.ustream.tv/recorded/18059942

Personally I'm working on an implementation, that uses the same idea as the UCM (a basic, abstract content type from which the other, concrete content types are derived). I had used that in a CMS I had built before I started using Joomla!. I'm using Doctrine2 ORM instead of JTable (or JDatabaseObject in eBay's UCM-proposal), as I don't want to reinvent the wheel again, but the UCM developers are not that enthusiastic about Doctrine2. See e.g. https://groups.google.com/forum/?fromgroups=#!topic/joomla-dev-framework/RXcyTMZsuXY

Unfortunately I've some other work to do too and so, although I had planned to deliver something useful this summer for this, it's fall allready now. But it is an interesting journey, worth the trouble. Even if that UCM would be delivered earlier than my work. One of the things I came across allready earlier when building a Joomla! component with Doctrine was that the ideas of a list and a form/item are a bit mixed: I have views that contain both, for instance a form with information about a performer, containing lists of acts and lists of media (pictures, videos). For me, delivering this is high priority, especially because this is where my passion lies, but some priorities (customers, income) unfortunately are higher.

Cliff Ford

unread,
Oct 2, 2012, 2:03:24 PM10/2/12
to joomla-de...@googlegroups.com
Do you know where Yannick's 'hello world' code is located? I could not find anything.

For my own amusement I created the directory structure for a new component (just like in all the tutorials) and put in just enough code to get some output. The site default controller execute method looks like this:

    public function execute()
    {
        // get the default model - extends JModelDatabase
        require_once JPATH_COMPONENT . '/models/default.php';
        // $state is a JRegistry object - not defined yet
        $this->model = new GreetDefaultModel($state);
        // get the view - extends JViewHtml
        require_once JPATH_COMPONENT . '/views/default/view.html.php';
        $queue = new SplPriorityQueue;
        $queue->insert(JPATH_COMPONENT . '/views/default/tmpl', 1);
        $view = new GreetDefaultView($this->model, $queue);
        $content = $view->render();
        echo $content; //"Hello World!";
    }
But I can't help wondering if this could possibly be the right way to do it. I read what the PHP manual had to say about SplPriorityQueue but I don't have any idea why it is used or how it is supposed to be used. So a peek at code written by someone who knows what he/she is doing might give me enough confidence to continue.

Cliff
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/GO30UIgTxLwJ.

elin

unread,
Oct 3, 2012, 9:01:51 AM10/3/12
to joomla-de...@googlegroups.com
I've been hesitating about pushing up my more complete local code using a more complete version because I'm not totally satisfied with it but this was my first pass and it does what it does fine 

Elin
To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.

Michael Babker

unread,
Oct 3, 2012, 9:06:07 AM10/3/12
to joomla-de...@googlegroups.com
Just to throw another example use of the new MVC out there, I had rewritten the CMS's install app to work with the new application and MVC classes.  This is an old version (I want to say it was last updated between 3.0 Alpha 1 and 2), but it does work for the most part.  https://github.com/mbabker/joomla-cms/tree/CmsInstall/installation

To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/68xkHrBpqwsJ.

To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.

elin

unread,
Oct 3, 2012, 10:52:59 AM10/3/12
to joomla-de...@googlegroups.com
I'd love to see us switch the installation as a first step.

Elin
Reply all
Reply to author
Forward
0 new messages