Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
<?php

/**
 * Adds a block and assigns it to "sample_block"
 */
block('sample_block', function() {
   $html = '<div class="block"><div class="title">Hello World!</div><div class="content">...</div></div>';

   return $html;
});


/**
 * Adds a block and assigns it to "sample_block_with_view" with an HTML view
 */
block('sample_block_with_view', function() {

   return view('@Sample/block.html');
});

 

!Important: Make sure to clear your sites cache after assigning a block.

Notes

...

Since 4.3+

Blocks are not required to be included in a route and is no longer the advised way to create a block. While old methods are still supported in 4.3, they will be depreciated in the future. The change in how blocks work in 4.3 is to give clients the ability to re-position your blocks from the AdminCP.

...