tynmar wrote:
/templates/components/com_foobar (here we could find all our templates, we can organize as we want because simple component doesn't always need 3 or 4 folders to view and modify a list)
Compare that with the Beez template. Look in:
/templates/beez/html/com_content/(view name)
tynmar wrote:
/components/com_foobar may contain
model.php
In Joomla! we tend to separate the Model, from the Table API, and we have one model per file, and one table per file.
In a mega-component like com_content we will have a table for articles, for categories and for sections (actually we stick those in the core libs, but that's beside the point). We generally have a model file for dealing with each type of view. So, we'd have a model that dealt with working with categories, and one that dealt with working just with articles. We have a base class called JModel that does a lot of work for you. JTable is just a rehash of the old mosDBTable class with a few extra perks.
tynmar wrote:
A clear view of our database structure in a file.
You could create classes
class fooBar extends somethingInJoomlaAPI
{
var $id = null; // impossible to tell it's an integer ? a varchar ? ...
}
class fooBarComments extends somethingInJoomlaAPI
{
var $id = null; // impossible to tell it's an integer ? a varchar ? ...
}
?>
That's a very Drupal way of doing things (and there's nothing wrong with that). However, in Joomla we have no concept of a base "node" or "thing" ... well, except JObject I guess. So in the above example if you are dealing with a Model, you do:
class fooBarModelComments extends JModel
and a view:
class fooBarViewComments extended JView
tynmar wrote:
controller.php
include('model');
switch($foo){
case 'bar':
doSomething();
break;
}
function doSomething(){
query...() loop()...
display('common.tpl'); (this is in the first template folder)
or redirect('somewhere');
}
?>
For the controller I took a note out of RoR's methodology. We don't use the switch statements anymore. Your controller looks something like this:
class fooBarController extends JController
{
function bar()
{
// do something
}
}
$controller = new fooBarController;
$controller->execute( 'bar' );
$controller->redirect();
?>
You pass a task into the controller and the controller looks for a function of that name. I'm actually really happy with the controller - it's a pretty neat class and it draws heavily on the other paradigms you quoted. The controller also has helper methods for doing redirection.
tynmar wrote:
You want to design friendly URL, Joomla cannot include regexp for urls ? I have to rewrite my htaccess ?
a file called
/component/com_foobar/urls.php
would be great.
You would use a file called:
/components/com_foobar/router.php
Basically it accepts an array and you have to pass one back - knock yourself out on the desired logic you want.
Hope this helps a little. You don't have to agree with it, but we have based the whole system heavily on the ruby and python examples and there is compromise involved - I'll grant you that. However, if you want Joomla to be Cake, or follow RoR religiously, you won't find that and that's not really a goal we ever set ourselves. It's more of a hybrid system that tries to find the line of best fit among many competing conditions and constraints.
_________________
Andrew Eddie - Tweet
@AndrewEddie<><
http://learn.theartofjoomla.com - Joomla 2.5 training videos!
http://www.kiva.org/team/joomla - Got Joomla for free? Pay it forward and help fight poverty.