Archived talk

Difference between revisions of "Developing a MVC Component/Adding backend actions"

From Joomla! Documentation

(→‎Model subtlety: new section)
Line 10: Line 10:
  
 
Note that the model loaded in the getModel function by the HelloWorlds controller (admin/controllers/helloworlds.php) is NOT the HelloWorlds model; it is instead the HelloWorld model. The HelloWorlds model (HelloWorldModelHelloWorlds) extends JModelList, which has no delete function. The HelloWorld model (HelloWorldModelHelloWorld) extends JModelAdmin, which has the delete function needed to delete items.
 
Note that the model loaded in the getModel function by the HelloWorlds controller (admin/controllers/helloworlds.php) is NOT the HelloWorlds model; it is instead the HelloWorld model. The HelloWorlds model (HelloWorldModelHelloWorlds) extends JModelList, which has no delete function. The HelloWorld model (HelloWorldModelHelloWorld) extends JModelAdmin, which has the delete function needed to delete items.
 +
 +
== Naming confusion ==
 +
I agree with the first user. helloworld is an abused word in the example. We could call the table greetings, so the models (greetings and greeting) and so on. Without using different and clear name the reader cannot understand the mechanism of the MVC pattern.

Revision as of 09:03, 4 August 2011

It's not clear to me where the word "helloworld" refers to in these examples. Can you please clarify when 'helloworld' refers to the component,controller,model,table,view or form? While following this, I've changed the name of my component, and when running this I get a 'call to member function getTable() on non-object'. It seems that I used the wrong name somewhere, but I have no idea where.

We're also introducing JForms and JFields. These are powerful and important, and warrant some richer explanation.

Attention![edit]

There is a change in /admin/views/helloworlds/tmpl/default_body.php that isnt mentioned on this page but is present in the archive file.

Model subtlety[edit]

Note that the model loaded in the getModel function by the HelloWorlds controller (admin/controllers/helloworlds.php) is NOT the HelloWorlds model; it is instead the HelloWorld model. The HelloWorlds model (HelloWorldModelHelloWorlds) extends JModelList, which has no delete function. The HelloWorld model (HelloWorldModelHelloWorld) extends JModelAdmin, which has the delete function needed to delete items.

Naming confusion[edit]

I agree with the first user. helloworld is an abused word in the example. We could call the table greetings, so the models (greetings and greeting) and so on. Without using different and clear name the reader cannot understand the mechanism of the MVC pattern.