Commit 4451785c authored by Michael Danielczok's avatar Michael Danielczok

feat: New setting for customer review brick: show max. number of random entires.

parent 9df61460
......@@ -592,6 +592,44 @@
</option>
</setting>
<setting name="random" type="select">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random"/>
<option value="off">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random.off"/>
</option>
<option value="1">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random.1"/>
</option>
<option value="2">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random.2"/>
</option>
<option value="3">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random.3"/>
</option>
<option value="4">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random.4"/>
</option>
<option value="5">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random.5"/>
</option>
<option value="6">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random.6"/>
</option>
<option value="7">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random.7"/>
</option>
<option value="8">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random.8"/>
</option>
<option value="9">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random.9"/>
</option>
<option value="10">
<locale group="quiqqer/bricks" var="bricks.customerReviews.random.10"/>
</option>
</setting>
<setting name="showAvatar" type="checkbox">
<locale group="quiqqer/bricks" var="bricks.customerReviews.showAvatar"/>
</setting>
......
......@@ -1245,6 +1245,55 @@ M&ouml;chten Sie die Bausteine aus der Bausteinzone entfernen?</p>]]></de>
<de><![CDATA[Kleine Boxen]]></de>
<en><![CDATA[Small boxes]]></en>
</locale>
<locale name="bricks.customerReviews.random">
<de><![CDATA[Random]]></de>
<en><![CDATA[Random]]></en>
</locale>
<locale name="bricks.customerReviews.random.off">
<de><![CDATA[Aus (alle anzeigen)]]></de>
<en><![CDATA[Off (show all entries)]]></en>
</locale>
<locale name="bricks.customerReviews.random.1">
<de><![CDATA[Zeige maximal 1 Eintrag]]></de>
<en><![CDATA[Show max. 1 entry]]></en>
</locale>
<locale name="bricks.customerReviews.random.2">
<de><![CDATA[Zeige maximal 2 Einträge]]></de>
<en><![CDATA[Show max. 2 entries]]></en>
</locale>
<locale name="bricks.customerReviews.random.3">
<de><![CDATA[Zeige maximal 3 Einträge]]></de>
<en><![CDATA[Show max. 3 entries]]></en>
</locale>
<locale name="bricks.customerReviews.random.4">
<de><![CDATA[Zeige maximal 4 Einträge]]></de>
<en><![CDATA[Show max. 4 entries]]></en>
</locale>
<locale name="bricks.customerReviews.random.5">
<de><![CDATA[Zeige maximal 5 Einträge]]></de>
<en><![CDATA[Show max. 5 entries]]></en>
</locale>
<locale name="bricks.customerReviews.random.6">
<de><![CDATA[Zeige maximal 6 Einträge]]></de>
<en><![CDATA[Show max. 6 entries]]></en>
</locale>
<locale name="bricks.customerReviews.random.7">
<de><![CDATA[Zeige maximal 7 Einträge]]></de>
<en><![CDATA[Show max. 7 entries]]></en>
</locale>
<locale name="bricks.customerReviews.random.8">
<de><![CDATA[Zeige maximal 8 Einträge]]></de>
<en><![CDATA[Show max. 8 entries]]></en>
</locale>
<locale name="bricks.customerReviews.random.9">
<de><![CDATA[Zeige maximal 9 Einträge]]></de>
<en><![CDATA[Show max. 9 entries]]></en>
</locale>
<locale name="bricks.customerReviews.random.10">
<de><![CDATA[Zeige maximal 10 Einträge]]></de>
<en><![CDATA[Show max. 10 entries]]></en>
</locale>
<locale name="bricks.customerReviews.entries">
<de><![CDATA[Meinungen / Rezensionen]]></de>
<en><![CDATA[Reviews]]></en>
......
......@@ -4,6 +4,8 @@
}
.customer-review {
display: flex;
flex-direction: column;
margin-bottom: 3em;
margin-right: 2em;
width: calc(33% - 1.5rem);
......@@ -16,6 +18,7 @@
.customer-review-content {
background: rgba(0, 0, 0, 0.02);
border: 1px solid #ddd;
flex-grow: 1;
margin-bottom: 1em;
padding: 2em;
}
......
......@@ -24,9 +24,10 @@ class CustomerReviews extends QUI\Control
{
// default options
$this->setAttributes([
'template' => 'wideBoxes',
'template' => 'wideBoxes',
'showAvatar' => true,
'entries' => []
'entries' => [],
'random' => 'off'
]);
parent::__construct($attributes);
......@@ -46,6 +47,26 @@ class CustomerReviews extends QUI\Control
$entries = json_decode($entries, true);
}
if ($this->getAttribute('random') !== 'off') {
$random = $this->getAttribute('random');
if ($random > count($entries)) {
$random = count($entries);
}
$keys = array_rand($entries, $random);
if (!is_array($keys)) {
$keys = [$keys];
}
foreach ($keys as $key) {
$randomEntries[] = $entries[$key];
}
$entries = $randomEntries;
}
switch ($this->getAttribute('template')) {
case 'smallBoxes':
$template = dirname(__FILE__) . '/CustomerReviews.SmallBoxes.html';
......@@ -60,8 +81,8 @@ class CustomerReviews extends QUI\Control
}
$Engine->assign([
'this' => $this,
'entries' => $entries,
'this' => $this,
'entries' => $entries,
'showAvatar' => $this->getAttribute('showAvatar')
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment