PHP code example of brandcom / cakephp-content-blocks
1. Go to this page and download the library: Download brandcom/cakephp-content-blocks 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/ */
brandcom / cakephp-content-blocks example snippets
public function getFields(): array
{
return array_merge(
parent::getFields(),
[
'title' => [
'label' => __("Block Title"),
],
'style' => [
'label' => __("Choose a style for this block."),
'options' => [
'default' => __("Default Style"),
'funky' => __("Other cool Style"),
],
],
]
);
}
public function getHiddenFields(): array
{
return array_merge(
parent::getHiddenFields(),
[
'some_field',
'another_hidden_field',
]
);
}
public function beforeFind(Event $event, Query $query): Query
{
return $query->contain([
'Images',
]);
}
public function getManagedModels(): array
{
return [
"SliderBlockSlides,"
];
}
public function getViewVariables($entity): array
{
$vars = parent::getViewVariables($entity);
return [
'article' => $vars['owner'],
'random' => "This is just a string",
'someOtherVariable' => $this->getSomeOtherVariable($entity),
];
}