feat(main): conform to Websmid module standards

This commit is contained in:
2026-06-23 13:18:57 +02:00
parent 9e6c26da38
commit 6aff506cd6
3 changed files with 10 additions and 8 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace Websmid\CustomHtml\Module;
use Websmid\CustomHtml\Model\CustomHtml;
use Context;
trait DisplayHooks
{
public function renderWidget($hookName = null, array $configuration = [])
{
if (empty($hookName)) {
return false;
}
$idLang = (int) Context::getContext()->language->id;
$templateFile = 'module:ws_customhtml/views/templates/hook/customhtml_block.tpl';
$cacheId = $this->getCacheId('ws_customhtml_' . $idLang . '_' . $hookName);
if (!$this->isCached($templateFile, $cacheId)) {
$variables = $this->getWidgetVariables($hookName, $configuration);
if (empty($variables)) {
return false;
}
$this->smarty->assign($variables);
}
return $this->fetch($templateFile, $cacheId);
}
public function getWidgetVariables($hookName = null, array $configuration = [])
{
$blockList = CustomHtml::getActiveByHookName((string) $hookName);
if (empty($blockList)) {
return [];
}
return [
'hookName' => $hookName,
'blockList' => $blockList,
];
}
}