block.accordion.php
Блок «Аккордеон»
Вызывается из:
Исходный код
<?php
ob_start();
if (isset($block['data']['list']) && is_array($block['data']['list'])) foreach ($block['data']['list'] as $item) {
if (!$item['active']) continue;
print '<li>';
print '<a class="uk-accordion-title">' . (strlen($item['title']) ? $item['title'] : ' ') . '</a>';
print '<div class="uk-accordion-content">';
print $item['html'];
print '</div>';
print '</li>';
}
if (!$html = ob_get_clean()) return;
$classNames = array('uk-accordion');
$options = array();
if ($block['data']['accordion-options']) foreach (is_array($block['data']['accordion-options']) ? $block['data']['accordion-options'] : explode('|', $block['data']['accordion-options']) as $option) if ($option) {
if (substr($option, 0, 3) === 'uk-') $classNames[] = $option;
elseif ($option === 'multiple') $options['multiple'] = 'true';
elseif ($option === 'no-collapsible') $options['collapsible'] = 'false';
}
if ($options) foreach ($options as $k => $v) if (is_string($k)) $options[$k] = $k . ': ' . $v;
print '<ul class="' . implode(' ', $classNames) . '" uk-accordion' . ($options ? '="' . htmlspecialchars(implode('; ', $options)) . '"' : '') . '>';
print $html;
print '</ul>';
?>
<script>
cmsRequire(['uikit']);
</script>
<?php
$html = ob_get_clean();
ob_start();
print $Main->callTemplate('block/block', 'block', $Page, array( 'block' => $block, 'html' => $html ));
?>