Component tutorial - strange behaviour

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 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.

Difficult to Follow Part 5,6

Apparently, the drills of Part 5 and 6 are difficult to follow even though the material is useful and not difficult. The talk in the very early beginning about the folder Admin & Site are not clarified anywhere here. We know Administrator folder in Joomla and if it is under component com_hello, ok but creation of it nor Admin are never mentioned. The difference between Administartor folder and Admin are not found in the page nor in the talks. In Part 1-3, I did drills 1 -3, but the downloaded com_hello1, 2, 3 woould not work by plug-in. The contents are important, so a simple clue is to re-write the explantions in Part 5 & 6 please.

"The talk in the very early beginning about the folder Admin & Site are not clarified anywhere here." --> Part 4 goes into depth about this! Part 5 is nothing more then a quick step-by-step creation of a non-functional/non-click-able table listing page as done before in parts 1,2 and 3 only now in admin folder (as is clearly stated in Part 4 and in the first 3/4 paragraphs of Part 5). If you have troubles with this I would suggest to re-read Parts 1 to 3 and in mind replace "site" with "admin". For Part 6 I agree that this is not an easy section. To understand PArt 6 though, you conceptually must understand the previous chapters. Parts 5 and 6 are not a step-through guide but expect that the concept of the previous chapters is basically understood.

BTW: the com_hello1, 2, 3 are working so something what you are doing is somewhere going wrong. Maybe a little blunt but programming a component is not something you can do on a Sunday afternoon. It is not copy and paste. The entire example simply helps with the fundamentals. If you find missing clicks in the documentation please discuss these specific items and we will help. Addressing the entire chapters as difficult doesn't add anything to the discussion. Of cause it is difficult, its called programming and that by itself is a profession. --M.A.S.H 14:44, 14 July 2010 (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?

Error in admin/controls/hello.php listing

I think that there is an error in the code for the file admin/controls/hello.php

line 55 of admin/controls/hello.php if ($model->store($post)) {

The method save() of the class HellosControllerHello passes the variable $post to the method store() of the class HellosModelHello. The variable $post does not seemed to be defined anywhere, it is not defined in the class HellosControllerHello, or the parent HellosController or in the grandparent JController. Also the function store() defined on line 79 of admin/models/hello.php, is defined as taking no arguments.

I hope that I have correctly identified a problem and not just made a fool of myself.

I would also like to say thank you for this tutorial, I'm totally new to Joomla! and am finding it very helpful. However I would agree with the other people who say that part6 is not as clear as the preceding parts.

Answer: $POST is a default PHP parameter containing all posted data. This parameter can always be used somewhere in PHP and is therefore not explained explicit.

I think I have found another possible error. The method store() of the class HellosModelHello calls the check() method of the TableHello object. However the TableHello class does not override the check() method of the base class JTable, and the method check() in the base class does nothing more than return true. I really can't see the point in calling check(), and I can't see the educational benefit of including it in this tutorial. Answer: As this is a tutorial, the concept is placed but indeed not used. It doesn't harm anything but can be used easily now for extending to your own taste.

Confusion

I'd like to second the comments about the confusion of step 6. I managed to follow steps 1-5 with the application of some serious thought but step 6 is mind boggling. This is mostly because the author(s) decided to call the specific model / view and controller the same damned thing as the default one but with one letter different! So we have the models/hellos.php and models/hello.php . We have views/hellos/view.html.php and views/hello/view.html.php.

Why couldn't we have something new like world for the specfic mv and c?! That way we can separate it easily in our minds until the new naming conventions are cemented in.

I found the naming conventions article really helpful on this. I get it now, but I wasted a lot of time trying to follow step 6.

I'd really appreciate it if there were some reminders throughout, such as:

- Remember that the model name is the same as the folder name for the view. - Remember that the default view file is called, view.html.php etc. If you're just learning these conventions then it is a lot to remember.

Content is available under Joomla! EDL unless otherwise noted.Joomla!® is a registered trademark of Open Source Matters, Inc.If you are experiencing technical issues with this website, please report it
.
Notice a content problem? Create an account
and fix it.