Description
...
null block(int $location, string $route, $callback_id, Closure $callback)
...
Requires: phpFox 4.3+
Creates Connects a block in specific locations and routes . based on the JSON Configuration assignment for blocks.
Parameters
...
$location$callback_id
Block location number.
$route
Route to place the block.
$callback
Callback function that will be executed when the block is to be loaded.
Examples
...
language | php |
---|
...
Assigning blocks in your app.json file.
Code Block |
---|
{
"id": "Sample",
"name": "My Sample App",
"version": 1,
"icon": "",
"blocks": [
{
"callback": "sample_block",
"route": "route_v",
"location": 3
},
{
"callback": "sample_block_with_view",
"route": "core.index-member",
"location": 3
}
]
} |
Connect block assignments in your start.php
Code Block |
---|
<?php /** * Adds a block inand videoassigns section.it to "sample_block" */ block(3, 'routesample_vblock', function() { $html = '<div class="block"><div class="title">Hello World!</div><div class="content">...</div></div>'; return $html; }); /** * Adds a block toand theassigns pollit section using to "sample_block_with_view" with an HTML view */ block(3, 'poll.index'sample_block_with_view', function() { return view('@Sample/block.html'); }); |
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.
...