feat(main): Add banner option

This commit is contained in:
2026-08-13 13:59:08 +02:00
parent fb641fc236
commit ce480314f3
22 changed files with 316 additions and 39 deletions
+4 -2
View File
@@ -3,6 +3,7 @@
namespace Websmid\CustomHtml\Module;
use Websmid\CustomHtml\Config\Config;
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PrestaShop\Core\Grid\Data\GridData;
use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection;
use Tools;
@@ -21,9 +22,10 @@ trait AdminHooks
public function hookActionAdminControllerSetMedia(): void
{
$controllerName = $this->context->controller->controller_name ?? '';
$request = SymfonyContainer::getInstance()->get('request_stack')->getCurrentRequest();
$routeName = $request ? (string) $request->attributes->get('_route') : '';
if (!in_array($controllerName, Config::ADMIN_CONTROLLERS, true)) {
if (0 !== strpos($routeName, 'customhtml')) {
return;
}
+14
View File
@@ -64,6 +64,7 @@ trait DisplayHooks
$blocksByGroup = CustomHtmlBlock::getActiveByGroupIds(array_column($groups, 'id_ws_customhtml_group'));
$blocksByGroup = $this->attachFaqsToBlocks($blocksByGroup);
$blocksByGroup = $this->attachBannerImageUrls($blocksByGroup);
$groups = array_map(static function (array $group) use ($blocksByGroup) {
$group['blocks'] = $blocksByGroup[(int) $group['id_ws_customhtml_group']] ?? [];
@@ -88,4 +89,17 @@ trait DisplayHooks
}, $blocks);
}, $blocksByGroup);
}
private function attachBannerImageUrls(array $blocksByGroup): array
{
return array_map(static function (array $blocks) {
return array_map(static function (array $block) {
if ($block['type'] === 'banner') {
$block['image_url'] = CustomHtmlBlock::getBannerImageUrl($block['image']);
}
return $block;
}, $blocks);
}, $blocksByGroup);
}
}
+4
View File
@@ -65,6 +65,10 @@ trait Install
`type` VARCHAR(32) NOT NULL DEFAULT \'html\',
`content` LONGTEXT,
`custom_class` VARCHAR(128) NOT NULL DEFAULT \'\',
`description` TEXT,
`extra_description` TEXT,
`link` VARCHAR(512) NOT NULL DEFAULT \'\',
`image` VARCHAR(255) NOT NULL DEFAULT \'\',
`active` TINYINT(1) NOT NULL DEFAULT 1,
`show_title` TINYINT(1) NOT NULL DEFAULT 0,
`ordering` INT(11) NOT NULL DEFAULT 0,