The name of an addon must be the same in addon.xml as the name of the directory the addon.xml is located in. So for our purposes, the name of our directory will be ‘movies’.
Inside of addons/movies are several standard files. You can download an archive of these files from
http:://www.ez-ms.com/private/movies1.tgz
It will probably make it easier to follow if you download it and install it somewhere and then use your favorite editor to follow along.
The main files in the addon are:
addon.xml - A description of the addon used by the system to install/uninstall it and to edit addon settings.
func.php - A php file included when it is determined the addon is installed.
init.php - A php file included during the ‘init’ stage of loading every page.
controllers/customer/movie.php - will be our controller for our ‘movie’ addon in the customer view.
Other files can be used like prepare.php if they exist but are not normally used in practice.
For now, we are only going to discuss the addon.xml file. We will describe what it does and when and some of the limitations that exist with its usage.
I’ve inserted comments in the addon.xml file here. These are not in the version you downloaded and this file will not function if cut/pasted. The goal is to use the lines of the file to describe what’s going on.
Addon.xml is loaded and parsed when the dispatch=?addons.manage page is loaded in the admin panel by clicking Administration/Addons. A DB lookup is performed to see if there is an entry for it in the ‘addons’ table. If not, then the addon is considered to NOT be installed. If there is, then it is considered to be installed.
A special note about the addon.xml… Once an addon is installed, updates to the addon.xml will not be seen (well, actually the form element will be seen, but not the label). So if you are considering other addon settings in your development, it’s best to put placeholders in for them even if they may not be used during your 1st version.
Comments in this addon.xml are prefixed on lines starting with EZ:
```php
EZ: standard xml header indicating the version of xml to be used.
EZ: The container name or root of the xml tree
movie
EZ: The name of the addon. This must match the name of the directory addon.xml is installed in.
Movies
EZ: What the movie addon’s title is or what’s seen in the list of addons
127
EZ: The priority of the addon. From 0 to 127. The higher the priority, the later hooks will be read.
EZ: This allows duplicate hooks to be prioritized in their execution. This is most important for
EZ: template override files since the last override wins.
0
EZ: The position of the addon in listings
active
EZ: active or disabled - the initial status after an install
EZ: Implemented in the DB and the addon.xml but not implemented by cs-cart. So it does nothing because they
EZ: haven’t had a need to finish the implementation yet.
EZ: This would contain any translations for the addon. Like whatever French is for the Name “Movies”.
EZ: These are the addon options
EZ: A unique id for each item
Max movies in block
EZ: name will become the label for the setting
input
EZ: one of several different types of form elements or text fields. See controllers/admin/addons.php for the options.
EZ: they change as cs-cart discovers they need new types. But they won’t add one if you need it and they don’t. Oops
EZ: will try to keep the editorials out of thise but there are some sore points.
EZ: An optional handler (name of a function) that will (or could) generate the value for the item
4
EZ: The default value to be used (if any).
EZ: Since this is the only setting we’re going to have, that’s it.
EZ: These are queries to be executed at install time or uninistall time.
EZ: Here we create a simple table to capture the value of our “is_movie” field and associate it to a product_id.
CREATE TABLE IF NOT EXISTS movies (
product_id mediumint(8) NOT NULL,
is_movie char(1) NOT NULL,
PRIMARY KEY (product_id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
EZ: We throw it away on uninstall. Note: this should not usually be done. It is done here to show it can be done.
EZ: But you might want to uninstall/install the addon for other reasons and you might not want to throw away all
EZ: your existing data.
DROP TABLE IF EXISTS movies;
EZ: Here are language variables to be set for this addon. They do not get unset when the addon is uninstalled.
EZ: I usually add language variables outside the addon.xml since it is not parsed again for languages or names
EZ: once the addon is installed. This means that if you add an item above, you won’t see the label until you uninstall
EZ: and reinstall. Again, they don’t have this problem so they won’t address it.
Is Movie
Max movies in block
Movies
EZ: Closing tag for the xml root
```
That’s it for this one. Given that this thread is not really being read much and no one seems to have any questions or discussion, I’m wondering if this is worth my time.
[quote name=‘tbirnseth’]That’s it for this one. Given that this thread is not really being read much and no one seems to have any questions or discussion, I’m wondering if this is worth my time.[/quote]
I’m reading them and wondering if your going to write a CS-Cart for Dummies book?
It is worth your time for me, But maybe others thought like I did, not to " interrupt" you with wasted posts like Good work and thanks etc.
I appreciate it and am learning something new so Thanks
I would add though that maybe if the thread title has “tuorial” or something in it, newbies would probably view it more, as 9 months ago I didnt know what a PHP Controller or addon.xml was so likely wouldnt bother reading the post.
Not sure on the newbie thing. This really isn’t for the faint at heart and there’s no way I can cover all info. I’m trying to share what I’ve learned by trial and error over the past couple of years but also know that people will have to do their own research to meet their specific needs. There are traps and holes and things that are not obvious.and hopefully I can explain them in a way tha keeps others from scratching their head for several days…
I’ll keep plugging away. But by all means, if any clarification is needed or there are questions I can fend, please ask.
Not sure on the newbie thing. This really isn’t for the faint at heart and there’s no way I can cover all info. I’m trying to share what I’ve learned by trial and error over the past couple of years but also know that people will have to do their own research to meet their specific needs. There are traps and holes and things that are not obvious.and hopefully I can explain them in a way tha keeps others from scratching their head for several days…
I’ll keep plugging away. But by all means, if any clarification is needed or there are questions I can fend, please ask.[/quote]
I’m reading these, I honestly don’t have much to comment as I haven’t started the acutal coding/learning process.
Despite this, it’s informative to understand structure - so thanks for posting!
What I don’t understand is if you’re in the business of selling addons, why would you want to show others how it’s done?
Regardless, you more than likely will not to see too much interest. The basic theme of the forum seems to be “What can I get for free with as little effort as possible?”.
[QUOTE]What I don’t understand is if you’re in the business of selling addons, why would you want to show others how it’s done?[/QUOTE]
“T” realizes that he will never be able to retire if he has to keep continually answering all of the forum questions regarding hooks, etc, so instead, soon he can just tell people to “read my book”.
[quote name=‘Struck’]“T” realizes that he will never be able to retire if he has to keep continually answering all of the forum questions regarding hooks, etc, so instead, soon he can just tell people to “read my book”.[/QUOTE]
He doesn’t have to keep continually doing anything aside from breathing, eating, sleeping.
Who knows, I may want a partner. This is a VERY SIMPLE example we’re using. Something like mailchimp are much more involved.
I think it’s best to educate. Probably due to my frustration with the cs-cart team who should be the ones doing this. They offer virtually no technical support for addon developers (unless you’re Russian of course) nor for rebranders. So I just thought I’d try to educate others on the very basic methods to do a very simple and general addon…
Maybe a book would be a good idea. But certainly couldn’t take that on without some advance royalties…
If cs-cart were smart, they’d fund this endeavor and make it really complete. But then they couldn’t change it at-will if it were actually documenated witn their name on it.
Starting from CS-Cart 3 a new addon.xml scheme is used. Add-ons with the old scheme will not be displayed in the Administration->Addons, nor will they work correctly without a proper scheme conversion"[/size][/font][/color]
You should be able to use the same addon.xml file for V3 as in V2. But note that anything placed in the var/skins_repository/base directory needs to be moved to the var/skins_repository/basic directory in V3.