init
This commit is contained in:
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Mageplaza\Blog\Block\Post\View;
|
||||
use Mageplaza\Blog\Model\Category;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var View $block */
|
||||
/** @var Escaper $escaper */
|
||||
|
||||
$post = $block->getPost();
|
||||
$category = $post->getSelectedCategoriesCollection()->getFirstItem();
|
||||
$publishDate = $post->getPublishDate()
|
||||
? $block->getDateFormat($post->getPublishDate())
|
||||
: '';
|
||||
$views = (int) $post->getViewTraffic();
|
||||
$socialShareHtml = trim($block->getChildHtml('social_share'));
|
||||
?>
|
||||
<header class="esun-news-detail-header">
|
||||
<?php /** @var Category $category */ ?>
|
||||
<?php if ($category->getId()): ?>
|
||||
<a class="esun-news-detail-header__category"
|
||||
href="<?= $escaper->escapeUrl($block->getCategoryUrl($category)) ?>">
|
||||
<?= $escaper->escapeHtml($category->getName()) ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<h1 class="esun-news-detail-header__title">
|
||||
<?= $escaper->escapeHtml($post->getName()) ?>
|
||||
</h1>
|
||||
|
||||
<div class="esun-news-detail-header__meta">
|
||||
<?php if ($publishDate): ?>
|
||||
<time datetime="<?= $escaper->escapeHtmlAttr($post->getPublishDate()) ?>"
|
||||
class="esun-news-detail-header__meta-item">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<rect x="3" y="5" width="18" height="16" rx="2"/>
|
||||
<path d="M16 3v4M8 3v4M3 10h18"/>
|
||||
<path d="M8 14h.01M12 14h.01M16 14h.01M8 18h.01M12 18h.01"/>
|
||||
</svg>
|
||||
<span><?= $escaper->escapeHtml($publishDate) ?></span>
|
||||
</time>
|
||||
<?php endif; ?>
|
||||
|
||||
<span class="esun-news-detail-header__meta-item">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6S2 12 2 12Z"/>
|
||||
<circle cx="12" cy="12" r="2.75"/>
|
||||
</svg>
|
||||
<span><?= $escaper->escapeHtml(__('%1 views', $views)) ?></span>
|
||||
</span>
|
||||
|
||||
<?php if ($socialShareHtml !== ''): ?>
|
||||
<div class="esun-news-detail-header__social-share"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr(__('Share this post')) ?>">
|
||||
<?= /* @noEscape */ $socialShareHtml ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</header>
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Mageplaza\Blog\Block\Listpost;
|
||||
use Mageplaza\Blog\Helper\Data as BlogHelper;
|
||||
use Mageplaza\Blog\Model\Post;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var Listpost $block */
|
||||
/** @var Escaper $escaper */
|
||||
|
||||
$postCollection = $block->getPostCollection();
|
||||
?>
|
||||
<div class="post-list-content esun-news-list" id="mpblog-list-container">
|
||||
<?php if ($postCollection && $postCollection->getSize()): ?>
|
||||
<div class="post-list-body">
|
||||
<?php /** @var Post $post */ ?>
|
||||
<?php foreach ($postCollection as $post): ?>
|
||||
<?php
|
||||
$postUrl = (string) $post->getUrl();
|
||||
$imageUrl = $post->getImage()
|
||||
? $block->resizeImage($post->getImage(), '600x')
|
||||
: $block->getViewFileUrl('Mageplaza_Blog::media/images/mageplaza-logo-default.png');
|
||||
$description = trim((string) preg_replace(
|
||||
'/\s+/u',
|
||||
' ',
|
||||
// phpcs:ignore Magento2.Functions.DiscouragedFunction
|
||||
html_entity_decode(
|
||||
strip_tags((string) $post->getShortDescription()),
|
||||
ENT_QUOTES | ENT_HTML5
|
||||
)
|
||||
));
|
||||
$publishDate = (string) $post->getPublishDate();
|
||||
$formattedDate = $block->dateTime->date('Y-m-d', $publishDate);
|
||||
$viewCount = (int) $post->getViewTraffic();
|
||||
$primaryCategory = null;
|
||||
$categories = $block->getBlogHelper()->getCategoryCollection($post->getCategoryIds());
|
||||
if ($categories) {
|
||||
foreach ($categories as $category) {
|
||||
$primaryCategory = $category;
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<article class="item product product-item post-list-item esun-news-list__item">
|
||||
<div class="post-item-wraper esun-news-list__card">
|
||||
<a class="post-image esun-news-list__image-link"
|
||||
href="<?= $escaper->escapeUrl($postUrl) ?>"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr($post->getName()) ?>">
|
||||
<img class="img-responsive esun-news-list__image"
|
||||
src="<?= $escaper->escapeUrl($imageUrl) ?>"
|
||||
alt="<?= $escaper->escapeHtmlAttr($post->getName()) ?>"
|
||||
loading="lazy" />
|
||||
</a>
|
||||
|
||||
<div class="post-info-wraper esun-news-list__content">
|
||||
<div class="mp-post-info esun-news-list__meta">
|
||||
<span class="esun-news-list__type">
|
||||
<?php if ($primaryCategory): ?>
|
||||
<a class="esun-news-list__category"
|
||||
href="<?= $escaper->escapeUrl($block->getBlogHelper()->getBlogUrl(
|
||||
$primaryCategory,
|
||||
BlogHelper::TYPE_CATEGORY
|
||||
)) ?>">
|
||||
<?= $escaper->escapeHtml($primaryCategory->getName()) ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h2 class="mp-post-title esun-news-list__title">
|
||||
<a class="post-link-title"
|
||||
href="<?= $escaper->escapeUrl($postUrl) ?>">
|
||||
<?= $escaper->escapeHtml($post->getName()) ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<?php if ($description): ?>
|
||||
<p class="post-short-description esun-news-list__description">
|
||||
<?= $escaper->escapeHtml($description) ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="esun-news-list__footer">
|
||||
<div class="esun-news-list__footer-meta">
|
||||
<time class="esun-news-list__date"
|
||||
datetime="<?= $escaper->escapeHtmlAttr($publishDate) ?>">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<rect x="3" y="5" width="18" height="16" rx="2" />
|
||||
<path d="M8 3v4M16 3v4M3 10h18" />
|
||||
</svg>
|
||||
<?= $escaper->escapeHtml($formattedDate) ?>
|
||||
</time>
|
||||
<?php if ($viewCount > 0): ?>
|
||||
<span class="esun-news-list__views"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr(__('%1 views', $viewCount)) ?>">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6Z" />
|
||||
<circle cx="12" cy="12" r="2.75" />
|
||||
</svg>
|
||||
<?= (int) $viewCount ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<a class="mp-read-more esun-news-list__read-more"
|
||||
href="<?= $escaper->escapeUrl($postUrl) ?>">
|
||||
<?= $escaper->escapeHtml(__('Read more')) ?>
|
||||
<span aria-hidden="true">→</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?= $block->getPagerHtml() ?>
|
||||
<?php else: ?>
|
||||
<p><?= $escaper->escapeHtml(__('There are no posts at this moment')) ?></p>
|
||||
<?php endif; ?>
|
||||
<?= $block->getChildHtml('additional') ?>
|
||||
</div>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Esun\Homepage\Block\NewsPostNavigation;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var NewsPostNavigation $block */
|
||||
/** @var Escaper $escaper */
|
||||
$previousPost = $block->getPreviousPost();
|
||||
$nextPost = $block->getNextPost();
|
||||
$storeId = $block->getCurrentStoreId();
|
||||
?>
|
||||
<?php if ($previousPost || $nextPost): ?>
|
||||
<nav class="esun-news-bottom-nav"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr(__('News previous and next')) ?>">
|
||||
<?php if ($previousPost): ?>
|
||||
<a class="esun-news-bottom-link esun-news-bottom-link--previous"
|
||||
href="<?= $escaper->escapeUrl($previousPost->getUrl($storeId)) ?>">
|
||||
<span class="esun-news-bottom-arrow" aria-hidden="true"></span>
|
||||
<span class="esun-news-bottom-text">
|
||||
<strong><?= $escaper->escapeHtml(__('Previous News')) ?></strong>
|
||||
<span><?= $escaper->escapeHtml((string) $previousPost->getName()) ?></span>
|
||||
</span>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span class="esun-news-bottom-link esun-news-bottom-link--previous is-disabled"
|
||||
aria-hidden="true"></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($nextPost): ?>
|
||||
<a class="esun-news-bottom-link esun-news-bottom-link--next"
|
||||
href="<?= $escaper->escapeUrl($nextPost->getUrl($storeId)) ?>">
|
||||
<span class="esun-news-bottom-text">
|
||||
<strong><?= $escaper->escapeHtml(__('Next News')) ?></strong>
|
||||
<span><?= $escaper->escapeHtml((string) $nextPost->getName()) ?></span>
|
||||
</span>
|
||||
<span class="esun-news-bottom-arrow esun-news-bottom-arrow--next" aria-hidden="true"></span>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span class="esun-news-bottom-link esun-news-bottom-link--next is-disabled"
|
||||
aria-hidden="true"></span>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user