To manage resources use resource library. It is designed to

We have following resource types



Example of extension that use resource library

We will create slideshow extension. It will have following features:

Here we will have a part of extension source. You can take a look at full code by downloading our free template. This extension is a part of template.

- create extensions/slideshow folder - create extensions/slideshow/config.xml


<?xml version="1.0"?>
<extension>
  	<id>slideshow</id>
  	<version>1.0</version>
  	<cartversions>
        	<item>0.9</item>
        <item>1.0</item>
  	</cartversions>
  	<priority>30</priority>
  	<type>extension</type>
  	<category>blocks</category>
  	<settings>
        	<item id="slideshow_status">
              	<type>checkbox</type>
              	<default_value>0</default_value>
        	</item>
        	<item id="slideshow_x">
              	<type>input</type>
              	<default_value>544</default_value>
        	</item>
        	<item id="slideshow_y">
              	<type>input</type>
              	<default_value>305</default_value>
        	</item>
  	</settings>
  	<additional_settings><![CDATA[blocks/slideshow]]></additional_settings>
  	<note>true</note>
  	<install>
        	<sql>install.sql</sql>
        	<trigger>install.php</trigger>
  	</install>
  	<uninstall>
        <sql>uninstall.sql</sql>
        	<trigger>uninstall.php</trigger>
  	</uninstall>
</extension>

In config we define size of slide ( slideshow_x, slideshow_y ) <additional_settings> tag define link for extension controller that will manage slides <note>true</note> - mean that will have description note for extension that will be shown on extension edit page. Note text is defined in language file with definition key = slideshow_note

- create install.sql. Table will keep slide img and slide url

CREATE TABLE IF NOT EXISTS `ac_slides` (
  	`slide_id` int(11) NOT NULL AUTO_INCREMENT,
  	`slide_img` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
  	`slide_url` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
  	PRIMARY KEY (`slide_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1;

INSERT INTO `ac_slides` ( `slide_img`, `slide_url` ) VALUES ( 'slides/slide1.jpg', 'http://google.com' );
INSERT INTO `ac_slides` ( `slide_img`, `slide_url` ) VALUES ( 'slides/slide2.jpg', 'http://bing.com' );
INSERT INTO `ac_slides` ( `slide_img`, `slide_url` ) VALUES ( 'slides/slide3.jpg', 'http://msn.com' );


- create uninstall.sql


DROP TABLE IF EXISTS `ac_slides`;


- create install.php. Here we will add block to layout. Container for our block will be content_top


<?php
if ( !defined ( 'DIR_CORE' )) {
  	header ( 'Location: static_pages/' );
}

$layout = new ALayoutManager();
$block_data = array(
    'block_txt_id' => 'slideshow',
    'controller' => 'blocks/slideshow',
    'templates' => array(
        array(
            'parent_block_txt_id' => 'content_top',
            'template' => 'blocks/slideshow.tpl',
        ),
	),
);
$layout->saveBlock( $block_data );