5.7 Documentation Update

Permalink 2 users found helpful
Hey everyone, just wanted to let you know I've pushed up a bunch of new documentation to the 5.7 docs. Getting better every day.

https://www.concrete5.org/documentation/developers/5.7/...

The blocks section is now completely finished. New today includes

* Complete screencast (over 40 minutes) on building an audio player
* Registering requiring CSS and Javascript using the new assets system
* Grouping blocks into sets
* Enabling inline editing for a block
* Disabling the grid container at the block type level
* Working with multiple database tables
* Interactive blocks, including how to present and submit a form within a block back to a block's controller, and how to use action URLs to change block output
* Including complex form widgets include file manager selector in blocks.
* Including blocks in packages

Additionally, the assets documentation is done, including

* Registering JavaScript and CSS assets in custom code or in a package
* Requiring assets in your block or single page code
* Grouping assets into groups (and why you'd want to)

And the first two appendixes, including

* Full Asset List
* Full HTML Form and Custom Widget Service listing.

Thanks for your patience. More next week!

andrew
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Excellent news, thank you Andrew.
martbase replied on at Permalink Reply
Awesome... Now more addons coming to 5.7
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi Andrew,

When registering and requiring assets, I am getting an error when Block Cache is turned on. When block cache is off, everything works as expected.
Argument 1 passed to Concrete\Core\Asset\AssetGroup::addGroup() must be an instance of Concrete\Core\Asset\AssetGroup, null given, called in C:\xampp\htdocs\concrete5\concrete\src\Http\ResponseAssetGroup.php on line 183 and defined

Here is an example of code I am using that throws the error.
public function on_start()
{
    $al = AssetList::getInstance();
    $al->register(
        'javascript', 'vegas', 'blocks/background_image_overlay/vegas/jquery.vegas.min.js',
        array('version' => '1.3.5', 'minify' => false, 'combine' => true),
        'background_image_overlay'
    );
    $al->registerGroup('vegas', array(
        array('javascript', 'jquery'),
        array('javascript', 'vegas'),
    ));
}
public function registerViewAssets()
{

Here is another example when using multiple types and asset handles.
public function on_start()
{
    $al = AssetList::getInstance();
    $al->register(
        'javascript', 'vegas', 'blocks/background_image_overlay/vegas/jquery.vegas.min.js',
        array('version' => '1.3.5', 'minify' => false, 'combine' => true),
        'background_image_overlay'
    );
    $al->register(
        'javascript', 'pants', 'blocks/background_image_overlay/vegas/monkeypants.js',
        array('version' => '2.5', 'minify' => true, 'combine' => true),
        'background_image_overlay'
    );
    $al->register(
        'css', 'vegas', 'blocks/background_image_overlay/vegas/vegas.css',

Is there a mistake in my code?
andrew replied on at Permalink Reply
andrew
Ah, interesting. I think if a block is cached it doesn't run on_start() or the view() method.

In the meantime you can probably register the assets in the registerViewAssets() before running requireAsset() and that would probably fix it. In the grand scheme of things we should probably run on_start() regardless of whether the block is cached or not.
MrKDilkington replied on at Permalink Reply
MrKDilkington
Thank you, moving everything (the asset registration and grouping) to registerViewAssets() works.

Based on the example I posted where multiple JavaScript files are registered. I found that the JS files will minify, but are not combining. Is this the expected behavior?

<script type="text/javascript" src="/concrete5/application/files/cache/js/118bebdd9874fec6db2ad18604fb464afdefa9c3.js" data-source="/concrete5/packages/background_image_overlay/blocks/background_image_overlay/vegas/jquery.vegas.min.js"></script>
<script type="text/javascript" src="/concrete5/application/files/cache/js/c32bc091463098bcd8dcb4fa7c53aa051412cfe1.js" data-source="/concrete5/packages/background_image_overlay/blocks/background_image_overlay/vegas/monkeypants.js"></script>