<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php
/**
 * Product list template
 *
 * @var $block \MGS\InstantSearch\Block\Blog\ListBlog
 */
?>
<?php
$_postCollection = $block->getLoadedPostCollection();
?>
<?php if (!$_postCollection->count()): ?>
	<div class="message info empty"><div><?php /* @escapeNotVerified */ echo __('We can\'t find posts matching the selection.') ?></div></div>
<?php else: ?>
	<?php
        $viewMode = 'grid';
        $showDescription = true;
    ?>
	<div class="posts wrapper <?php /* @escapeNotVerified */ echo $viewMode; ?> posts-<?php /* @escapeNotVerified */ echo $viewMode; ?> blog-grid blog-post-item">
		<div class="block block-title title-blog text-center">
			<h4><?= __('Blogs') ?></h4>
		</div>
		<?php $iterator = 1; ?>
		<div class="top-toolbar"><?= $block->getToolbarHtml() ?></div>
		<ol class="line row-3 row-tablet-3 row-mobile-2 items post-items">
			<?php /** @var $_post \MGS\Blog\Model\Post */ ?>
			<?php foreach ($_postCollection as $_post): ?>
				<?php /* @escapeNotVerified */ echo($iterator++ == 1) ? '<li class="col item post post-item">' : '</li><li class="col item post post-item">' ?>
					<div class="post-item-info post-images mg-bottom-55" data-container="post-grid">
						<?php // Post Image ?>
						<div class="post-thumbnail">
							<a href="<?php /* @escapeNotVerified */ echo $_post->getPostUrlWithNoCategory() ?>" class="post-thumbnail--image" style="background-image:url('<?= $block->getImageThumbnailPost($_post); ?>');" tabindex="-1" title="<?= $_post->getTitle(); ?>">	                    	
								<img class="post-image-photo" src="<?= $block->getImageThumbnailPost($_post); ?>" alt="<?php /* @escapeNotVerified */ echo $_post->getTitle() ?>"/>
							</a>
						</div>
						<div class="post post-metas">
							<a class="link-item"
							   href="<?php /* @escapeNotVerified */ echo $_post->getPostUrlWithNoCategory() ?>">
								<?php /* @escapeNotVerified */ echo $_post->getTitle() ?>
							</a>
							<div class="meta-date">
								<span class="color-theme"><?php /* @escapeNotVerified */ echo $_post->getUser(); ?></span>
								<span class="color-date"><?php /* @escapeNotVerified */ echo $block->formatDate($_post->getCreatedAt(), \IntlDateFormatter::MEDIUM, false); ?></span>
							</div>
						</div>
					</div>
				<?=($iterator == count($_postCollection)+1) ? '</li>' : '' ?>
			<?php endforeach; ?>
		</ol>
		<div class="bottom-toolbar"><?= $block->getToolbarHtml() ?></div>
	</div>
<?php endif; ?>
