<?php if ($items): ?>
    <ul>
        <?php foreach ($items as $item): ?>
            <?php if (property_exists($item, 'items')): ?>
                <?php if ($item->items): ?>
                    <li class="group" data-status="<?= $this->getGroupStatus($item->title) ? 'expanded' : 'collapsed' ?>">
                        <h4><a href="javascript:;"><?= e($item->title) ?></a></h4>
                        <?= $this->makePartial('items', ['items'=>$item->items, 'nested'=>true]) ?>
                    </li>
                <?php endif ?>
            <?php else: ?>
            <?php
                $dataId = $this->itemType.'-'.$this->theme->getDirName().'-'.$item->fileName;
            ?>
                <li class="item" data-item-path="<?= e($item->fileName) ?>" data-item-theme="<?= e($this->theme->getDirName()) ?>" data-item-type="<?= $this->itemType ?>" data-id="<?= e($dataId) ?>">
                    <a href="#">
                        <span class="title"><?= e($item->title) ?></span>
                        <span class="description">
                            <?php foreach ($item->descriptions as $title => $value): ?>
                                <?php if (strlen($value)): ?>
                                    <?= e($title) ?>: <strong><?= e($value) ?></strong>
                                <?php endif ?>
                            <?php endforeach ?>

                            <?= e($item->description) ?>
                        </span>
                        <span class="borders"></span>
                    </a>

                    <input type="hidden" name="template[<?= e($item->fileName) ?>]" value="0"/>
                    <div class="checkbox custom-checkbox nolabel">
                        <?php $cbId = 'cb'.md5($item->fileName) ?>
                        <input
                            id="<?= $cbId ?>" 
                            type="checkbox"
                            name="template[<?= e($item->fileName) ?>]"
                            <?= $this->isTemplateSelected($item) ? 'checked' : null ?>
                            data-request="<?= $this->getEventHandler('onSelect') ?>"
                            value="1">
                        <label for="<?= $cbId ?>">Select</label>
                    </div>
                </li>
            <?php endif ?>
        <?php endforeach ?>
    </ul>
<?php else: ?>
    <p class="no-data"><?= e(trans($this->noRecordsMessage)) ?></p>
<?php endif ?>

<?php if (!isset($nested)): ?>
    <input type="hidden" name="theme" value="<?= e($this->theme->getDirName()) ?>">
<?php endif ?>