https://github.com/xanweb/c5-helpers
Concrete5 Helpers Suite
https://github.com/xanweb/c5-helpers
concrete5 concrete5-v8 concretecms concretecms-v9 helpers php php7
Last synced: about 1 month ago
JSON representation
Concrete5 Helpers Suite
- Host: GitHub
- URL: https://github.com/xanweb/c5-helpers
- Owner: Xanweb
- License: mit
- Created: 2020-02-18T14:25:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-23T10:41:00.000Z (over 3 years ago)
- Last Synced: 2025-04-10T21:18:30.451Z (about 2 months ago)
- Topics: concrete5, concrete5-v8, concretecms, concretecms-v9, helpers, php, php7
- Language: PHP
- Homepage:
- Size: 73.2 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ConcreteCMS Helpers Suite
[](https://packagist.org/packages/xanweb/c5-helpers)
[](LICENSE)Collection of useful helpers for ConcreteCMS
- `in_array_all` Verify that all needles are in haystack array.
- `in_array_any` Verify that at least one of needles is in haystack array.
- `strip_spaces` Remove all spaces from the given string.
- `current_locale` Get Current Page Locale.
- `current_language` Get Current Page Language.
- `active_locale` An Alias of \Localization::activeLocale().
- `active_language` An Alias of \Localization::activeLanguage().
- `theme_path` Get Site Theme Path
- `c5_date_format` An Alias of \Concrete\Core\Localization\Service\Date::formatDate().
- `c5_date_format_custom` An Alias of \Concrete\Core\Localization\Service\Date::formatCustom().
- `Xanweb\Helper\Page::getBlock` and `Xanweb\Helper\Page::getBlocks` for fetching block(s) from page## Installation
Include library to your composer.json
```bash
composer require xanweb/c5-helpers
```#### Usage of Xanweb\Helper\Page
```php
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
*/
```