J1.5 talk

Difference between revisions of "Developing a MVC Component/Adding Backend Actions"

From Joomla! Documentation

(Found an Error (I think))
(Multiple Tables: new section)
Line 48: Line 48:
--[[User:UsagiYojimbo|UsagiYojimbo]] 09:33, 19 October 2009 (UTC)
--[[User:UsagiYojimbo|UsagiYojimbo]] 09:33, 19 October 2009 (UTC)
== Multiple Tables ==
I have a relatively complex table layout, so naming a single table the same as my component isn't going to work. How can I account for multiple tables?

Revision as of 14:10, 23 October 2009

Component tutorial - strange behaviour

Thanks for the documentation.

Was not sure where to bring up questions about if the actual component itself has an error in it or not. I have started a topic in the forum [1]

Step 6 is very difficult to follow

In the last 3 days i've gone through the tutorial from the start. I've been doing website development for a while (2 years) but am new to both Joomla and the MVC pattern. I hand coded everything into my IDE (netbeans) after reading through the article (I'd skim read through once, then go back and try and create the component) steps 1-3 are very simple and easy to follow.

So when I got stuck I went to compare my component with the zipped one supplied... uh huh... they were/are totally different?

Where did the admin 'controllers' folder come from?
Why is there only 1 controller file in the admin 'controllers' folder this seems redundant and unexplained - surely you only need a folder for controllers if multiple controllers are required? Doing this to the hello example seems to be complicating things unnessecarily.

Having re-read this step several times I don't think it's mentioned in 'Getting Down and Dirty: Doing the Real Work' you should have created the folder 'controllers' in /administrator/components/com_hello/admin (if it is it's certainly not obvious).

Step 4 begins to get complex and I think maybe where the root of my trouble with step 6 is (I think it would benefit hugely from the suggestions in: ).

Step 6 doesn't give enough information about where the new admin files should be created and how they'd be named, it seems to supply source code with too little consideration to context in terms of filepaths. It would probably benefit to being broken down again into smaller parts.

I'll try and actually make recommendations about this in the next week or so (i'm at work at the moment so i'll try and do this from home).

Remarks to above

I agree that grasping the concept the first time immediately is a big nut to crack. The bigger the crack the tastier the nut ;). From your comments you may want to re-read Part 4 , it goes into detail about the configuration and site/administrator deviations.

To a certain extend I too got first lost in the name conventions but this made the deviation clear between site and administrator. The first paragraph of part 5 points out the difference of using the administrator side and the naming conventions, Part 5 - Tutorial specific naming. Looking back now the naming is more then plausible. I agree that the switch van site component development to administrator needs to be more explicit. I have added a comment now to Part 5 that Part 5 and 6 are only focussed on the admin side and that the site sub directory is not touched any more and there is an explicit reference to the XML file in the example.

In detail to your questions: you need two controllers. One for the default showing and another for the handling of editing/deletion actions. Non-default controllers must be placed in the controllers directory, that is how it is meant to be. This Hello controller might seem a little bit alone in that directory but this if following the MVC implementation ... and trust me, you will need this more then you might expect now (4/5 dedicated controllers are not uncommon, see also book lending example in Part 4). You are right that nowhere a reference to the controllers directory was made, that is corrected by me now.

With respect to your last comment I agree that only using this tutorial is not fully covering the details. On one hand we must improve it but on the other hand the answers are in the attached example file, copying the content of the example files into this tutorial makes it long to read and that is not helping either. The tutorial and example must be used together; adding some more references to the source files might be a good idea. Look at the bright side; by this mistake, I made it too to be honest, the complete architecture and interaction between the files is obvious now ;) This mistake has learned me more that all the things I copied/followed step-by-step.

--M.A.S.H 11:18, 27 September 2009 (UTC)

Found an Error (I think)

In the paragraph 4. Creating the Table Class there is a listing of a JTable class.

This class has the name TableHello. Its constructor method is called TableHello(), which is incorrect, as PHP classes' constructor should be named __construct().

This same mistake exists in the downloadable component, too.

--UsagiYojimbo 09:10, 12 October 2009 (UTC)

I corrected the listing, but not the downloadable component.

--UsagiYojimbo 09:33, 19 October 2009 (UTC)

Multiple Tables

I have a relatively complex table layout, so naming a single table the same as my component isn't going to work. How can I account for multiple tables?