LdcContentBlock provides an easy mechanism for adding view layer content blocks that receive and render ViewModel
s sent to them.
An example use case: Say your module provides a dashboard. Adding an LdcContentBlock to the page will allow other modules in the system to hook into that block and display their own custom widgets without having to modify the source of the module providing the dashboard itself.
-
Install the Composer package:
composer require adamlundrigan/ldc-content-block:1.*@stable
-
Enable the module (
LdcContentBlock
) in your ZF2 application. -
Add a content block to one of your view scripts:
<?=$this->renderContentBlock('my_block_name'); ?>
-
Configure something to inject into the block
-
Profit!
If you're fortunate enough to be on a *nix system with PHP >=5.4, pop into the demo
folder and run the setup script (run.sh
). This will build the demo application, install the example modules, and start a webserver. Once that's all done just open your browser and navigate to http://localhost:8080/
to see the blocks in action!