Actions

J1.5 talk

Difference between revisions of "Developing a MVC Component/Introduction"

From Joomla! Documentation

(Creating the View)
(Creating the View)
Line 15: Line 15:
 
site/components/com_{componentname}/views/{componentname}/view.html.php
 
site/components/com_{componentname}/views/{componentname}/view.html.php
  
--EdwardT
+
--Edwardt
  
 
== Typo on page? ==
 
== Typo on page? ==

Revision as of 10:45, 23 August 2009

Contents

Creating the View

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:

site/views/{viewname}

but rather:

site/components/com_{componentname}/views/{componentname}/view.html.php

--Edwardt

Typo on page?

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

JRequest::getVar('controller')

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

EdwardT


Question on fonts

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!

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

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

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.