xanweb/c5-helpers
最新稳定版本:v2.1
Composer 安装命令:
composer require xanweb/c5-helpers
包简介
ConcreteCMS Helpers Suite
README 文档
README
Collection of useful helpers for ConcreteCMS
in_array_allVerify that all needles are in haystack array.in_array_anyVerify that at least one of needles is in haystack array.strip_spacesRemove all spaces from the given string.current_localeGet Current Page Locale.current_languageGet Current Page Language.active_localeAn Alias of \Localization::activeLocale().active_languageAn Alias of \Localization::activeLanguage().theme_pathGet Site Theme Pathc5_date_formatAn Alias of \Concrete\Core\Localization\Service\Date::formatDate().c5_date_format_customAn Alias of \Concrete\Core\Localization\Service\Date::formatCustom().Xanweb\Helper\Page::getBlockandXanweb\Helper\Page::getBlocksfor fetching block(s) from page
Installation
Include library to your composer.json
composer require xanweb/c5-helpers
Usage of Xanweb\Helper\Page
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 required block $contentBlockController = $ph->getBlock( 'content', // Block Type Handle function (BlockController $bController) { // Optional callable to test for valid block return !empty($bController->getContent()); } ); // Get the first valid instances of required blocks $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 */
统计信息
- 总下载量: 602
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 2
- 依赖项目数: 2
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-18