J1.5 talk

Developing a MVC Component/Introduction

From Joomla! Documentation

(Redirected from Talk:Developing a Model-View-Controller Component - Part 1)

Wish for continuation[edit]

Hello, I'd like to see one more part on ordering. Thank you in advance.

Creating the View[edit]

One thing that's not mentioned on the page is how Joomla knows to go to view.html.php.

Unlike controller.php, it's not called anywhere in the code.

In fact, this appears to be a default setting in Joomla. See the page on Naming Conventions: http://docs.joomla.org/Naming_conventions.

This page also appears to have a few typos (!) as the file isn't stored at:


but rather:



Typo on page?[edit]

Hi, new to this, so hope this is the right place.

I'm working through the example.

I notice that the code for 'hello.php' has the line:

if($controller = JRequest::getWord('controller')) {

Whereas the accompanying text uses


It seems to me that the getVar function makes more sense so should the code for hello.php be changed?


Question on fonts[edit]

is there anyway to make the font for ".source-php .kw1" a more printer friendly color yet still be distinguishable as important text? At the very least lets make the font "bold" so it is stronger in contrast. Even in the highest quality setting on printer it appears very washed out to these old eyes.

You can add your own stylesheet to override any of the system-generated styles by adding a special subpage under your user page. In your case, create the page User:N6REJ/monobook.css and add your CSS rules into it. Chris Davenport 08:55, 19 January 2009 (UTC)

Use lowercase file and folder names in your components![edit]

When creating custom components try to use file names and folder names with all lowercase letters. I had created some complex MVC components, naming my folders and files after my classes in the component. This meant that I had upper and lowercase letters in the folder and file names. During testing on my Windows machine everything worked fine, but when I transfered to a remote host running unix, nothing worked properly. The errors provided by the framework were only slightly helpful in identifying the root cause which was that the JPath:: class implicitly calls strtolower() on all paths. Therefore my files were not being found by the framework. I hope this helps save someone some time.

View naming conventions[edit]

It should probably be mentioned that the naming of the "view" script is strictly as named here; Joomla looks for "view.html.php" for the class to render HTML, and "view.feed.php" for a feed display, etc. I at first omitted the ".html" double extension from my file, and quickly ran into errors, so it might be best to mention that, the same way the entry point file name has to match the component name. --MidnightLightning 16:35, 6 April 2009 (UTC)

Tutorial articles detected ...[edit]

Double tutorial detected, older but somehow different (especially Part 4) Tutorial:Developing_a_Model-View-Controller_Component_-_Part_1. these Tutorial pages are all marked now as double but a manual merge might be needed.

Inconsistent naming of install.xml file in Part 1[edit]

The tutorial begins in Part 1 as naming the XML file the same as the component (ie, hello.xml). Later in Part 3 without any explanation the XML file is now referred to as install.xml.

Should hello.xml in Part 1 be renamed to install.xml?

Site Directory[edit]

Am I right in thinking that the site directory is the name of the component? Or is it given to represent the path to the place where the files are stored? Wouldn't it be better to have com_hello as the component name? Or to have something like site_path to indicate what we mean instead of just "site"? I just found this a little confusing during following the tutorial.

You mean "Creating a Component" section? No, that's about structure of component distribution (usually com_hello.zip). Joomla will create components/com_hello for the content of "site" directory ("site" directory name isn't an example).