Hi,
we're probably hijacking this thread, but anyway ...
How to do things always depends on what is needed :-) There's no general rule or "law".
Let me just clarify my statement about Views and their Models. This was taken from JView::setModel(&$model, $default = false):
We support a multiple model single view system by which models are referenced by classname. A caveat to the classname referencing is that any classname prepended by JModel will be referenced by the name without JModel, eg. JModelCategory is just Category.
If you look at this method's signature it's indeed the standard behaviour to
add new models to the list. It's just that if you don't do anything -- literally --, the framework will derive the names, classes and file locations of the default model and layout from the view's name.
When I wrote "it's not indented to be used that way", I meant you should not replace a view's default model by another "default". A specific view ought to provide at least the same default data, but it may of course be extended with
extra data for use in additional layouts.
This is exactly what happens in com_content: the article view, at the very least, contains the data of an article -- that's the default, but some "layouts" can also display the category or section an article belongs to. Whether they show up depends on com_content's and the menuitem's parameters. If these parameters tell com_content that categories will be required that is they're
expected by the chosen layout, it'll load and add the category and/or section models, and the layout template may then access this extra information via additional properties and methods.
The amount of items may change or their ordering, but the default data isn't: you still have things like $title or $introtext from the default model.
Now, do you always have to include the whole iCal library?
I don't know. This (again) depends on the tasks your component provides and how it's supposed to provide the data to the user and certainly how this data is stored on your server.
If it's "default" job is to
parse iCal files for display in an HTML page -- some event calender or such --, it's probably a good idea to only include these parts of the library to reduce weight. On the other hand, if -- what I suppose happens as well -- somone downloads an .ical file (set of events), this
download task would probably just need the library parts the create/render this structure.
Does this require different
models? I'm not too familiar with iCal, but I think there's not much difference in the resulting "colums" or "fields" and hierarchy whether the data comes from an iCal file or from the database. I'm pretty sure that iCalender library already provides some interface or data structure, and this should basically become the blueprint for your implementation inside Joomla.
What's probably special about this, are the possibly different
data-sources: on the one hand it's some special formatted "text file", and on the other it's the database (I suppose) --
or maybe both?
Will users upload their .ical files in some way?
Will those files be located on the file system?
Do you have a database table with a big text column that will contain the "native" iCalender data; like jos_content contains "native" HTML for each article?
Will you break each "event" into pieces and make it a record on its own? with individual columns?
Or is there a combination of all?
:-)
All this makes "it depends" the only possible answer to whether or not you should include the whole iCalendar library, and if you can get along with one (default) model for each view or several adjacent models.
If the library is split into a parser and renderer,
I would load the required parts/classes only when they're needed. Maybe write a "helper" class with utilities or
decorators for the incoming and outgoing data.
Make outlines and a feature lists of each intended "view" and its presentation, and each action/task your component will provide. Think about the various layouts and how they need the calender data to be structured, ordered, filtered, etc. A "view by month" probably requires a different model than a "view by title" or "view by category", and so does a "details view".
Have fun,
CirTap