In this final session, we’re going to create a ‘Filling type’ for a “products block” that will limit the contents of the block to only those products with ‘is_movie=‘Y’’.
To do this, we need to add 2 more admin files to the addon. These are:
addons/movie/schemas/block_manager/structure.post.php
addons/movie/schemas/block_manager/specific_settings.post.php
For structure.post.php things are pretty simple. This is where we set our $params value that will be passed to our get_products hook.
if ( !defined('AREA') ) { die('Access denied'); }
// This is what gets passed in the $param array of our get_products hook
$schema['products']['fillings']['movie'] = array ('params' => array('movies'=>true));
specific_settings.post.php will use our default value for the maximum number of products to list in our block, but the merchant can still change it in the block settings area.
if ( !defined('AREA') ) { die('Access denied'); }
$schema['fillings']['movie'] = array (
'limit' => array (
'type' => 'input',
'default_value' => Registry::get('addons.movie.max_movies_in_block'),
)
);
Both of these ‘schemas’ simply add definition to the system data. To configure, open the block manager and create a new block called “Current Movies”.
The contents of the block should be ‘Products’ and the ‘Filling type’ should be ‘Movies’. If you click the ‘specific settings’ link for the ‘Filling’ you will see your default ‘limit’.
That’s basically it. Of course, you could extend this by having a movie viewer in the block or have a special movie preview file specified in the product, etc. But we’ll leave that for an exercise for the reader.
Notice that there was not one change to a standard core file. Everything was done through the addon itself. Hence if you uninstall or disable the addon, none of the changes to the system will be reflected. This is one of the best things about cs-cart from a developer’s pespective. Now if they’d just learn to listen to the few requsts that have been made (even though it doesn’t affect them) it could be a very viable platform to do some really cool extensions for. But after 2 years of trying, I’ve given up.
Have fun… Happy debugging.
Final archive is:
[url]http://www.ez-ms.com/private/movie4.tgz[/url]