<?php
$dataHelper = $block->getDataHelper();
$storeCode = $dataHelper->getCurrentStoreCode();
$_pages = $block->getPageCollection($storeCode);
?>
<div id="els-cms-results">
<?php if ($_pages && count($_pages)): ?>
    <div class="block block-compare result-list">
        <div class="block-title">
            <strong><?php echo __('Page Results') ?></strong>
            <span class="counter"><?php echo __('%1', count($_pages)) ?></span>
        </div>
        <div class="block-content">
            <ul>
                <?php foreach ($_pages as $_page): /** @var \Magento\Cms\Model\Page $_page */ ?>
                    <li>
                        <a href="<?php echo $block->escapeUrl($block->getBaseUrl() . $_page['identifier']) ?>"
                           title="<?php echo $block->escapeHtml($_page['title']) ?>">
                            <?php echo $_page['title'] ?>
                        </a>
                    </li>
                <?php endforeach; ?>
            </ul>
        </div>
    </div>
<?php endif; ?>
</div>

<script id="els-cms-results-template" type="text/x-magento-template">
    <div class="block block-compare result-list">
        <div class="block-title">
            <strong><?= __('Page Results') ?></strong>
            <span class="counter"><%= count %></span>
        </div>
        <div class="block-content">
            <ul>
                <% _.each(cms, function(doc) { %>
                <li>
                    <a href="<%= _.getBaseUrl() + doc.identifier %>"
                       title="<%= doc.title %>">
                        <%= doc.title %>
                    </a>
                </li>
                <% }) %>
            </ul>
        </div>
    </div>
</script>

