PHP code example of xanweb / c5-helpers
1. Go to this page and download the library: Download xanweb/c5-helpers library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xanweb / c5-helpers example snippets
use Xanweb\Helper\Page as PageHelper;
$ph = new PageHelper(
$page, // Page Object
['Header', 'Footer'], // Optional argument to exclude some areas from fetching
['Main'] // Optional argument to include some areas in fetching
);
// Get the first valid instance of
$blocksControllers = $ph->getBlocks(
['image', 'content'], // Block Types Handle
function (BlockController $bController) { // Optional callable to test for valid block
if ($bController instanceof \Concrete\Block\Image\Controller) {
return is_object($this->getFileObject());
}
if ($bController instanceof \Concrete\Block\Content\Controller) {
return !empty($bController->getContent());
}
return false;
}
);
/**
* - $blocksControllers array is indexed by btHandle: ['image' => $bController, 'content' => $bController]
* - If no block is found $blocksControllers will be an empty array
*/