init
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
use Mageplaza\Blog\Block\Sidebar\MostView;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var MostView $block */
|
||||
/** @var Escaper $escaper */
|
||||
$posts = $block->getMostViewPosts();
|
||||
$postsRecent = $block->getRecentPost();
|
||||
?>
|
||||
<div class="mp-sidebar product info detailed">
|
||||
<div class="product data items" data-mage-init='{"tabs":{"openedState":"active"}}'>
|
||||
<div class="data item title" data-role="collapsible" id="tab-label-popular">
|
||||
<a class="data switch" tabindex="-1" data-toggle="switch" id="tab-label-popular-title">
|
||||
<div><?= $escaper->escapeHtml(__('Popular')) ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="data item content" id="tab-content-popular" data-role="content">
|
||||
<?php if ($posts->getSize()) : ?>
|
||||
<?php foreach ($posts as $post) : ?>
|
||||
<div class="list-post-tabs">
|
||||
<div class="post-left">
|
||||
<a href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<img class="img-responsive"
|
||||
src="<?= $escaper->escapeUrl($block->resizeImage($post->getImage(), '100x')) ?>">
|
||||
</a>
|
||||
</div>
|
||||
<div class="post-right">
|
||||
<a href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<span><?= $escaper->escapeHtml($post->getName()) ?></span>
|
||||
</a>
|
||||
<span class="create-at">
|
||||
<?= $post->getPublishDate()
|
||||
? $escaper->escapeHtml($block->getDateFormat($post->getPublishDate())) : '' ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="mp-clear"></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<div class="mostview-nopost"><?= $escaper->escapeHtml(__('No Posts')) ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="data item title" data-role="collapsible" id="tab-label-mostview">
|
||||
<a class="data switch" tabindex="-1" data-toggle="switch" id="tab-label-mostview-title">
|
||||
<div><?= $escaper->escapeHtml(__('Latest')) ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="data item content" id="tab-content-mostview" data-role="content">
|
||||
<?php if ($postsRecent->getSize()) : ?>
|
||||
<?php foreach ($postsRecent as $post) : ?>
|
||||
<div class="list-post-tabs" href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<div class="post-left">
|
||||
<a href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<img class="img-responsive"
|
||||
src="<?= $escaper->escapeUrl($block->resizeImage($post->getImage(), '100x')) ?>">
|
||||
</a>
|
||||
</div>
|
||||
<div class="post-right">
|
||||
<a href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<span><?= $escaper->escapeHtml($post->getName()) ?></span>
|
||||
</a>
|
||||
<span class="create-at">
|
||||
<?= $post->getPublishDate()
|
||||
? $escaper->escapeHtml($block->getDateFormat($post->getPublishDate())) : '' ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="mp-clear"></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<div class="mostview-nopost"><?= $escaper->escapeHtml(__('No Posts')) ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
require([
|
||||
'jquery'
|
||||
], function ($) {
|
||||
$("#popular-tab").click(function () {
|
||||
$("#tab-1").addClass('active');
|
||||
$("#tab-2").removeClass('active');
|
||||
$('#mostview').show();
|
||||
$('#mostrecent').hide();
|
||||
});
|
||||
$("#recent-tab").click(function () {
|
||||
$("#tab-1").removeClass('active');
|
||||
$("#tab-2").addClass('active');
|
||||
$('#mostview').hide();
|
||||
$('#mostrecent').show();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
use Mageplaza\Blog\Block\Sidebar\Search;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var Search $block */
|
||||
/** @var Escaper $escaper */
|
||||
?>
|
||||
<style>
|
||||
.sidebar.sidebar-main:before {
|
||||
content: unset;
|
||||
}
|
||||
</style>
|
||||
<div class="mpblog-search">
|
||||
<div class="field search">
|
||||
<label class="label" for="mpblog-search-box" data-role="minisearch-label">
|
||||
<span><?= $escaper->escapeHtml(__('Search')) ?></span>
|
||||
</label>
|
||||
<div class="control">
|
||||
<input id="mpblog-search-box"
|
||||
type="text"
|
||||
name="query"
|
||||
value="<?= $escaper->escapeHtmlAttr($block->getRequest()->getParam('query')) ?>"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('Search blogs here...')) ?>"
|
||||
class="input-text"
|
||||
role="combobox"
|
||||
aria-haspopup="false"
|
||||
aria-autocomplete="both"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button type="submit" title="<?= $escaper->escapeHtmlAttr(__('Search')) ?>" class="action search">
|
||||
<i class="fa fa-search" aria-hidden="true" style="font-size: 16px;margin-top: 5px;"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
require(['jquery', 'mpDevbridgeAutocomplete'], function ($) {
|
||||
var visibleImage = <?= /** @noEscape */ $block->getSidebarConfig('search/show_image') ?>;
|
||||
|
||||
$('#mpblog-search-box').autocomplete({
|
||||
lookup: <?= /** @noEscape */ $block->getSearchBlogData() ?>,
|
||||
lookupLimit: <?= $block->getSidebarConfig('search/search_limit') ?: 10; ?>,
|
||||
maxHeight: 2000,
|
||||
minChars: <?= $block->getSidebarConfig('search/min_chars') ?: 1; ?>,
|
||||
autoSelectFirst: true,
|
||||
showNoSuggestionNotice: true,
|
||||
triggerSelectOnValidInput: false,
|
||||
onSelect: function (suggestion) {
|
||||
window.location.href = suggestion.url;
|
||||
},
|
||||
formatResult: function (suggestion, currentValue) {
|
||||
var additionClass = '',
|
||||
html = "<div class='mpblog-suggestion'>";
|
||||
|
||||
if (visibleImage) {
|
||||
html += "<div class='mpblog-suggestion-left'><img class='img-responsive' src='" + suggestion.image + "' /></div>";
|
||||
additionClass = 'image-visible';
|
||||
}
|
||||
|
||||
html += "<div class='mpblog-suggestion-right " + additionClass + "'>" +
|
||||
"<div class='mpblog-product-line mpblog-product-name'>" + suggestion.value + "</div>" +
|
||||
"<div class='mpblog-product-des'><p class='mpblog-short-des'>" + suggestion.desc + "</p></div></div></div>";
|
||||
|
||||
return html;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user