views:

38

answers:

2

I'm working on a joomla component that includes building a schedule. On any given day it needs to look at a set of rules (day of the week, date of the year, type of event) and return all of the possible start times. It would make sense to have a class that calculates these things, but I'm not sure it fits in the model or controller (and certainly not view) categories. Am I supposed to create a com_myproject/lib (or similar name) and have joomla auto-load the classes?

I'm new to joomla and started with the framework/project provided at http://docs.joomla.org/Building_Joomla_Extensions_with_Apache_Ant.

+1  A: 

You should create a helper class. Have a look here for an example, albeit it is for a module, but the same concept applies.

Martin
A: 

You might want to start off with Developing a Model-View-Controller Component - Part 1 tutorial and work your way through that by hand. Using Apache Ant to learn how write an extension is like taking a canon to shoot fish in the barrel. It can be done but probably not the best way of doing it.

The Joomla! MVC pattern is very peculiar and difficult to understand. I don't quite understand it myself. I was advised on the developer email list to look at how other components are put together. Guess what? All the other developers do it differently, with some of the bigger components looking like spaghetti code in their organization.

The bulk of your component code should be in the controller, either as part of the controller class or a separate class file that's imported in. You don't need a separate library directory unless you're working on a big component with multiple class files. This Joomla! thread might be applicable.

C.D. Reimer
I already went over all 6 parts of that tutorial, but none of it is clear where you put classes that are not directly an individual model, view, or controller.
Asa Ayers
"Using Apache Ant to learn how write an extension is like taking a canon to shoot fish in the barrel" I completely disagree with this. Its a complete wast of time for me to attempt to write in one folder, zip it, install it and repeat the process. Using Ant I create my source directory, package and install and then I just update the code in joomla's directory. Ant will pull those files back into my source so I can rebuild and install only when I have something ready to use.
Asa Ayers
I guess I'm old school then. I just recently switched from a text editor to an IDE and SVN. :) From my perspective, ANT is cannon because it adds a layer of complexity that I'm not used to yet. Thanks for explaining it.
C.D. Reimer