PHP Controller - 6 (The finalle)

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]

Thanks





JOhn

I bookmarked all 6 Threads. Concise and good roadmap. Thanks.

It's great work tbirnseth!

Whole your “PHP Controller” series is extremly helpful.

Thank you!

Good work dear @[color=#282828][font=arial, verdana, tahoma, sans-serif]tbirnseth[/font][/color]

Great series! Any chance of any more to come?

I can't understand how to do the following…


[quote name='tbirnseth' timestamp='1297027048' post='103180']

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.

[/quote]



What kind of block should I open?

Also, I can't find the [color=#282828][font=arial, verdana, tahoma, sans-serif]detailed_content.tpl …[/font][/color]

If you have followed the prior steps in the tutorial or you have dnnwloaded the archives that contain the example code then your system should be configured to support the “Filling type” of 'Movies". All the rest are standard block operations (V2). The “specific settings” should also have the limit setting if you have done the previous steps properly.

Here's where I'm stuck…

I go to the design page, I click “Add block” on the grid that I want and then the “Adding block to grid” page appears. What do I do next? I select the “Create new block” tab?? What's the option that I must choose???

how about linking all 6 parts ? we can’t find in this badly written search ;)



http://forum.cs-cart.com/index.php?app=core&module=search&section=search&do=search&fromsearch=1

Sorry, it's probably becoming out of date now that Pro is going away and only Ultimate and Mult-vendor remains. Moving my development efforts to a longer lasting product.

[quote name='tbirnseth' timestamp='1347062714' post='144550']Sorry, it's probably becoming out of date now that Pro is going away and only Ultimate and Mult-vendor remains. Moving my development efforts to a longer lasting product.[/quote]



Are you moving away from cscart or just professional? I didn't know they were ending professional.