I am new to Joomla dev, but an MVC design old timer. I'm developing a huge component in Joomla 3.0.1, but cant find a very good tutorial on what the Joomla MVC really makes possible. I have several questions. I come from DJANGO, in my opinion the bets MVC, but I am trying out joomla due to my companies desire.
What SHOULD I do with models and NOT with views.
What Variable can I throw at a view from a controller without putting them in the url. Do I have to use Globals?
I'll just answer your questions generically as you didn't ask for specifics.
It sounds like you know MVC well, so just use MVC best practices with Joomla. IE. Controllers pick the model, tell it to retrieve the data, then controllers choose the view, and assign the model, and any other data/variables it wants, to the view. Models should only retrieve and store data, Views should not have to know which model got the data, and the controller worries about all that. Your controller or sub controller can assign any variable it wants to a view.
FYI, some of the Joomla core components and many third party extensions have a bunch of logic in the views that using MVC best practices belong in the controllers, but it doesn't have to be that way, so just use best practices.
> I am new to Joomla dev, but an MVC design old timer. I'm developing a > huge component in Joomla 3.0.1, but cant find a very good tutorial on > what the Joomla MVC really makes possible.
> I have several questions. I come from DJANGO, in my opinion the bets > MVC, but I am trying out joomla due to my companies desire.
> What SHOULD I do with models and NOT with views.
> What Variable can I throw at a view from a controller without putting > them in the url. Do I have to use Globals?
> -- > You received this message because you are subscribed to the Google > Groups "Joomla! CMS Development" group.
> To view this discussion on the web, visit > https://groups.google.com/d/msg/joomla-dev-cms/-/bmXrKJFlV-gJ.
> To post to this group, send an email to joomla-dev-cms@googlegroups.com.
> To unsubscribe from this group, send email to > joomla-dev-cms+unsubscribe@googlegroups.com.
> For more options, visit this group at > http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
Hi there.
Starting point is the documentation page (docs.joomla.org), especially
series 'Developing a Model-View-Controlller Component in Joomla 2.5':
http://docs.joomla.org/Developing_a_Model-View-Controller_(MVC)_Compo....
(I read somewhere there will be an update for 3.0). It takes about one
afternoon to read trough, but it's the best thing to start with.
You might also take a look how some simpler component work
(com_weblinks) and start with the frontend part (/components/
com_contact).
Don't get distracted by fact that in Jooma 2.5+ MVC component classes
have *Legacy suffix. This means that there is new MVC package
available, but CMS doesn't use it yet (transition will take some time
and IMHO it's more convenient for non-CMS purposes like webapps).
Globals are considered an antipattern. Controllers create models and
views, assign variables to models and execute methods. Actually much
this is happening under the cover by base classes (like you don't need
own 'display' method, because base class determines which view and
model are related to current request and passes variables to these).
On Nov 8, 7:29 pm, ChristisKing <austin.generalgr...@gmail.com> wrote:
> I am new to Joomla dev, but an MVC design old timer. I'm developing a huge
> component in Joomla 3.0.1, but cant find a very good tutorial on what the
> Joomla MVC really makes possible.
> I have several questions. I come from DJANGO, in my opinion the bets MVC,
> but I am trying out joomla due to my companies desire.
> What SHOULD I do with models and NOT with views.
> What Variable can I throw at a view from a controller without putting them
> in the url. Do I have to use Globals?
> I have several questions. I come from DJANGO, in my opinion the best MVC, > but I am trying out joomla due to my companies desire.
> I too love django ORM.... the differences with Joomla is the flow. Django
entry points are the view function that the urls are mapped to. Joomla follows more of a MVC design pattern whereas django kinda blends the Controller and View(Django seems more like Model,View,Template). Joomla's controller is where you parse request variables(using an object JInput), pass them to the models(JModelLegacy), instantiate a view(JViewLegacy), pass model/models instances to the view($view->setModel( $model )), and display the view($view->display()). The Views are similar to django only being different because the view doesn't necessarily instantiate the models, but uses the models and persists variables to be passed into the templates using $this->varname and from your templates accessing using $this->varname ($this context is the view object). Thats my shotgun blast of an answer!
What SHOULD I do with models and NOT with views.
I usually just stay away from any db access in the Views if i find myself wanting to do that I create a model. In Joomla models you will be dealing with table classes, using JInput to create sql queries..etc.... you will be writing alot more sql in your models. Sorry No ORM yet - any takers?
> What Variable can I throw at a view from a controller without putting them > in the url. Do I have to use Globals?
The only variables that you should be throwing at the view are models,and setting the layout, but you can set request variables inside the controller and use JInput to access them inside your view.
Look at the router.php in the com_content component as a example of routing so you dont go crazy expecting things to magically happen. Django urls.py is much easier....