feat(main): Add FAQ accordion

This commit is contained in:
2026-08-11 13:25:06 +02:00
parent 635c13a0ed
commit 1493081602
22 changed files with 459 additions and 4 deletions
+5 -1
View File
@@ -16,6 +16,9 @@ class CustomHtmlBlock extends ObjectModel
/** @var string */
public $title = '';
/** @var string */
public $type = 'html';
/** @var string */
public $content = '';
@@ -40,6 +43,7 @@ class CustomHtmlBlock extends ObjectModel
'fields' => [
'id_ws_customhtml_group' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'title' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 256],
'type' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32],
'content' => ['type' => self::TYPE_HTML, 'validate' => 'isCleanHtml'],
'active' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'show_title' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
@@ -58,7 +62,7 @@ class CustomHtmlBlock extends ObjectModel
}
$result = Db::getInstance()->executeS(
'SELECT `id_ws_customhtml`, `id_ws_customhtml_group`, `title`, `content`, `active`, `show_title`, `ordering`
'SELECT `id_ws_customhtml`, `id_ws_customhtml_group`, `title`, `type`, `content`, `active`, `show_title`, `ordering`
FROM `' . _DB_PREFIX_ . 'ws_customhtml`
WHERE `id_ws_customhtml_group` IN (' . implode(',', $groupIds) . ')
AND `active` = 1
+60
View File
@@ -0,0 +1,60 @@
<?php
namespace Websmid\CustomHtml\Model;
use ObjectModel;
use Db;
class CustomHtmlFaq extends ObjectModel
{
/** @var int */
public $id;
/** @var int */
public $id_ws_customhtml;
/** @var string */
public $question = '';
/** @var string */
public $answer = '';
/** @var int */
public $ordering = 0;
/** @var string */
public $date_add;
/** @var string */
public $date_upd;
public static $definition = [
'table' => 'ws_customhtml_faq',
'primary' => 'id_ws_customhtml_faq',
'fields' => [
'id_ws_customhtml' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'question' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 512],
'answer' => ['type' => self::TYPE_HTML, 'validate' => 'isCleanHtml'],
'ordering' => ['type' => self::TYPE_INT, 'validate' => 'isInt'],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
],
];
public static function getByBlockId(int $idBlock): array
{
$result = Db::getInstance()->executeS(
'SELECT `id_ws_customhtml_faq`, `question`, `answer`, `ordering`
FROM `' . _DB_PREFIX_ . 'ws_customhtml_faq`
WHERE `id_ws_customhtml` = ' . (int) $idBlock . '
ORDER BY `ordering` ASC'
);
return $result ?: [];
}
public static function deleteByBlockId(int $idBlock): void
{
Db::getInstance()->delete('ws_customhtml_faq', '`id_ws_customhtml` = ' . (int) $idBlock);
}
}