-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathrecent.phtml
executable file
·76 lines (73 loc) · 3.12 KB
/
recent.phtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* Copyright © Magefan ([email protected]). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
?>
<?php
/**
* Blog sidebar posts list template
*
* @var $block \Magefan\Blog\Block\Post\PostList\AbstractList
*/
?>
<?php
$_postCollection = $block->getPostCollection();
?>
<?php
$width = (int)$block->getWidth() ?: 300;
$height = (int)$block->getHeight() ?: 200;
$imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class);
?>
<?php if ($_postCollection->count()) { ?>
<div class="widget block block-<?= $block->escapeHtml(str_replace('_', '-', $block->getWidgetKey())) ?> block-list-posts" >
<div class="block-title">
<strong><?= $block->escapeHtml(__($block->getBlockTitle() ?: 'Recent Posts')) ?></strong>
</div>
<div class="block-content">
<?php foreach ($_postCollection as $_post) { ?>
<?php
$_postUrl = $block->escapeUrl($_post->getPostUrl());
$_postName = $block->escapeHtml($_post->getTitle());
?>
<div class="item clearfix">
<?php if ($block->getDisplayImage()) { ?>
<?php $featuredImage = $_post->getFeaturedListImage() ?: $_post->getFeaturedImage(); ?>
<div class="post-image">
<?php
$featuredImgAlt = $_post->getData('featured_list_img_alt') ?: $_post->getData('featured_img_alt');
if (!$featuredImgAlt) {
$featuredImgAlt = $_postName;
}
?>
<a class="post-item-link" title="<?= $_postName ?>" href="<?= $_postUrl ?>">
<?php
if ($featuredImage) {
$featuredImageUrl = $imageHelper->init($_post->getFeaturedListImg() ?: $_post->getFeaturedImg())->resize($width, $height);
} else {
$featuredImageUrl = $this->getViewFileUrl('Magefan_Blog::images/default-no-image.png');
}
?>
<img src="<?= $block->escapeUrl($featuredImageUrl) ?>"
alt="<?= $block->escapeHtml($featuredImgAlt) ?>"
width="<?= $width ?>"
height="<?= $height ?>"
/>
</a>
</div>
<?php } ?>
<a class="post-item-link" title="<?= $_postName ?>" href="<?= $_postUrl ?>">
<?= $_postName ?>
</a>
<?php if ($block->getDisplayImage() && $_post->isPublishDateEnabled()) { ?>
<div class="post-item-date">
<span class="value"><?= $block->escapeHtml($_post->getPublishDate()) ?></span>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
<?php } ?>