Example of extension with listing block

Extension with listing block wrapper (appearance controller)

1. Load custom listing block settings to the layout. Best way to do this is via XML load.

2. Add a hook into your extension on ControllerPagesDesignBlocks (Control Panel side). This will add controller(wrapper) to selection in control panel and show listing on storefront using your templates.

public function onControllerPagesDesignBlocks_InitData() {
$this->baseObject->data[ 'block_wrappers' ]['blocks/extension_listing_controller'] = '[extension_name]';

3. In main.php file of your extension add list of templates which will be used in list view. Number of templates depends on your block listing extensions controller.

$templates = array(
    'storefront' => array('blocks/some-template-name1.tpl',

4. Place above template files into folder «[extension_name]/storefront/view/default/templates/blocks/»  

5. Create listing block controller file in «[extension_name]/storefront/controller/blocks»

if (! defined ( 'DIR_CORE' )) {
	header ( 'Location: static_pages/' );
class ControllerBlocksExtensionName extends AController {
	public $data;
	public function main() {

        //init controller data

		$block_data = func_get_args(1);
		$parent_block_txt_id = $block_data[0];
		$block_data = $block_data[1];

			$this->view->assign('heading_title', $block_data['title'] );
				case 'content_top':
					$template = ''blocks/some-template-name1.tpl'';
				case 'column_left':
					$template = ''blocks/some-template-name3.tpl'';
				case 'column_right':
					$template = ''blocks/some-template-name4.tpl'';

					$template = ''blocks/some-template-name2.tpl'';
			$this->processTemplate( $template );



6. Add your controller into main.php to $controllers array:

$controllers = array(
    'storefront' => array('blocks/[extension_name]' ));