Skip to content
Code-Schnipsel Gruppen Projekte
Commit 2da948c1 erstellt von Michael Danielczok's avatar Michael Danielczok
Dateien durchsuchen

feat: Use FAQ schema markup [Accordion].

Übergeordneter 54af319a
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -37,4 +37,8 @@
{/if}
</div>
{/foreach}
{if $useFaqStructuredData}
{$this->createJSONLDFAQSchemaCode()}
{/if}
</div>
\ No newline at end of file
......@@ -15,6 +15,16 @@
*/
class Accordion extends QUI\Control
{
/**
* [
* 'entryTitle' => string,
* 'entryContent' => string
* ]
*
* @var array
*/
protected array $entries = [];
/**
* constructor
*
......@@ -24,13 +34,14 @@ public function __construct($attributes = [])
{
// default options
$this->setAttributes([
'nodeName' => 'section',
'class' => 'quiqqer-accordion',
'qui-class' => 'package/quiqqer/bricks/bin/Controls/Accordion',
'stayOpen' => false, // if true make accordion items stay open when another item is opened
'openFirst' => false, // the first entry is initially opened
'listMaxWidth' => 0, // positive numbers only, 0 disabled this option.
'entries' => []
'nodeName' => 'section',
'class' => 'quiqqer-accordion',
'qui-class' => 'package/quiqqer/bricks/bin/Controls/Accordion',
'stayOpen' => false, // if true make accordion items stay open when another item is opened
'openFirst' => false, // the first entry is initially opened
'listMaxWidth' => 0, // positive numbers only, 0 disabled this option.
'entries' => [],
'useFaqStructuredData' => false
]);
parent::__construct($attributes);
......@@ -64,13 +75,34 @@ public function getBody()
$entries = json_decode($entries, true);
}
$this->entries = $entries;
$Engine->assign([
'this' => $this,
'openFirst' => $this->getAttribute('openFirst'),
'listMaxWidth' => $maxWidth,
'entries' => $entries
'this' => $this,
'openFirst' => $this->getAttribute('openFirst'),
'listMaxWidth' => $maxWidth,
'entries' => $this->entries,
'useFaqStructuredData' => $this->getAttribute('useFaqStructuredData')
]);
return $Engine->fetch(dirname(__FILE__).'/Accordion.html');
}
/**
* Generate JSON-LD FAQ Schema Code
*
* @return string
* @throws QUI\Exception
*/
public function createJSONLDFAQSchemaCode()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Engine->assign([
'this' => $this,
'entries' => $this->entries
]);
return $Engine->fetch(dirname(__FILE__).'/Accordion.JSON-LD-Schema.html');
}
}
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren