Model View Controller
Posted: Fri Sep 07, 2007 2:28 am
Hi,
Took me long enough to understand - here is a little diagram explaining how I think the model view controller works. (please correct me if you think that I am wrong!!)
Most of the components that I have found in Joomla! have static views as 'entry points' to the component. They have no model and are therefore static. Alternatively they have helper classes pulling content in (like the 'article' view of com_content. Once we are in the component, every form, every link points back to index.php and passes the paramters 'option' and 'task' to Joomla. (Either as hidden values in forms or url paramters on links.)
Once that's done, Joomla jumps the component which is defined in '$option'. Once we are there the controller matches the task value against a member function within its class. That function then pulls in the right model and view and tells the view which layout to use.
The view itself pulls in the data from the model to populate itself,
Is that correct?
P.S I am currently working on an example component. During that process I document my prgress on my blog. Once the component is finished (possibly Wednesday next week) I will offer the component as free download. Feel free to have a look already...
http://www.uwe-duesing.com/index.php/joomla-blog#component
Took me long enough to understand - here is a little diagram explaining how I think the model view controller works. (please correct me if you think that I am wrong!!)
Most of the components that I have found in Joomla! have static views as 'entry points' to the component. They have no model and are therefore static. Alternatively they have helper classes pulling content in (like the 'article' view of com_content. Once we are in the component, every form, every link points back to index.php and passes the paramters 'option' and 'task' to Joomla. (Either as hidden values in forms or url paramters on links.)
Once that's done, Joomla jumps the component which is defined in '$option'. Once we are there the controller matches the task value against a member function within its class. That function then pulls in the right model and view and tells the view which layout to use.
The view itself pulls in the data from the model to populate itself,
Is that correct?
P.S I am currently working on an example component. During that process I document my prgress on my blog. Once the component is finished (possibly Wednesday next week) I will offer the component as free download. Feel free to have a look already...
http://www.uwe-duesing.com/index.php/joomla-blog#component