Create components for Joomla! - The example component
How to write a component for Joomla!TM 1.5 with Joomla!Component Builder
Develop components with Joomla!Component Builder is relatively easy because the program will write all the skeleton of the component in this way the generator components allows the programmer to focus only on business logic, or over which is his main task.
In order to explain how to act on a component generated by the generator components, we are writing this series of articles that explain how to create a simple online catalog for a. .. Well, I will not say, let's see if you can guess.
This is the structure of three of the tables needed by our customer, we will use it to create a component with Joomla!Component Builder, enter these three tables in a database for Joomla! 1.5 and create the component with the program ...
--
- Table structure for table mlm_ccat_categories
- This table contains the categories of brands
- (Hand-xxx, xxx mechanized, accessories)
--
CREATE TABLE IF NOT EXISTS `mlm_ccat_categories` (
`id` int (11) NOT NULL auto_increment,
`published` tinyint (1) NOT NULL default '1 ',
`ordering` int (11) NOT NULL default '100 ',
`category` varchar (80) NOT NULL,
`description` text NOT NULL,
PRIMARY KEY ( `id`)
) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1;
--
- Table structure for table `` mlm_ccat_brands
- This table contains the brands of individual products
--
CREATE TABLE IF NOT EXISTS `mlm_ccat_brands` (
`id` int (11) NOT NULL auto_increment,
`category_id` int (11) NOT NULL default '0 'COMMENT' link to ccat_categories',
`ordering` int (11) NOT NULL default '100 ',
`published` tinyint (1) NOT NULL default '1 ',
`name` varchar (100) NOT NULL,
`description` text,
image_small `` varchar (60) default NULL,
`image` varchar (60) default NULL,
PRIMARY KEY ( `id`)
) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1;
--
- Table structure for table `` mlm_ccat_products
- This table, finally, contains the Sigolo products
--
CREATE TABLE IF NOT EXISTS `mlm_ccat_products` (
`id` int (11) NOT NULL auto_increment,
`published` tinyint (1) NOT NULL default '1 ',
`ordering` int (11) NOT NULL default '100 ',
sku_code `` varchar (10) NOT NULL,
brand_id `` int (11) NOT NULL default '0 'COMMENT' link to ccat_brands',
`name` varchar (50) NOT NULL,
`description` text NOT NULL,
`image` varchar (50) NOT NULL,
pack_number `` int (11) NOT NULL default '0 ',
c_vitolas `` varchar (30) NOT NULL,
c_len `` int (11) NOT NULL default '0 ',
c_cepo `` int (11) NOT NULL default '0 ',
price_single `` float NOT NULL default '0 ',
price_pack `` float NOT NULL default '0 ',
PRIMARY KEY ( `id`)
) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1;
Note the presence in each table, of the three fields:
- `Id` int (11) NOT NULL auto_increment
- `Published` tinyint (1) NOT NULL default '1 '
- `Ordering` int (11) NOT NULL default '100 '
and an indication of the primary key PRIMARY KEY ( `id`).
sql file with some sample data can be downloaded here:
Now create the component, according to the instructions, and using this data
- safe name: ccat
- names for listing: ccatbrands, ccatcategories, ccatproducts
- names for each record: ccatbrand, ccatcategory, ccatproduct
Now you are ready to follow, if you will, instructions for use profitably Joomla!Component Builder in your work.
Add to your favorite Bookmarking / Aggiungi ai tuoi segnalibri prferiti