init
This commit is contained in:
@@ -0,0 +1,268 @@
|
||||
<?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\Author\SignupForm;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var SignupForm $block */
|
||||
/** @var Escaper $escaper */
|
||||
$author = $block->getAuthor();
|
||||
|
||||
?>
|
||||
<form enctype="multipart/form-data"
|
||||
action="<?= $escaper->escapeHtml($block->getUrl('mpblog/author/register')) ?>" method="post" class="form"
|
||||
name="mp_blog_author_form"
|
||||
id="blog_signup_author"
|
||||
>
|
||||
<?= /* @noEscape */
|
||||
$block->getBlockHtml('formkey'); ?>
|
||||
<fieldset class="fieldset">
|
||||
<div class="legend border-b pb-px">
|
||||
<legend>
|
||||
<span><?= /* @noEscape */
|
||||
$author['name'] === '' ? __('Signup Author') : __('Author Information') ?></span>
|
||||
</legend>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="field required mp-field ">
|
||||
<label for="name" class="label"><span><?= $escaper->escapeHtml(__('Display Name ')) ?></span></label>
|
||||
<div class="control">
|
||||
<input type="text" name="name" id="name" value="<?= $escaper->escapeHtml($author['name']) ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Display Name')) ?>"
|
||||
class="input-text" data-validate='{"required": true}'>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (isset($author['status'])) : ?>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label for="name" class="label"><span><?= $escaper->escapeHtml(__('Status')) ?></span></label>
|
||||
<div class="control">
|
||||
<span><?= $escaper->escapeHtml($author['status']) ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="field mp-field mb-2">
|
||||
<label for="short_desciption" class="label">
|
||||
<span><?= $escaper->escapeHtml(__('Short Description')) ?></span>
|
||||
</label>
|
||||
<div class="control">
|
||||
<textarea name="short_description" id="short_description" rows="5" cols="19">
|
||||
<?= /* @noEscape */
|
||||
$author['short_description']
|
||||
? $block->getPageFilter($author['short_description']) : '' ?>
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label for="image" class="label"><span><?= /* @noEscape */
|
||||
__('Avatar') ?></span></label>
|
||||
<div class="control" style="display: flex">
|
||||
<?php if (!empty($author['image'])) : ?>
|
||||
<a class="mp-image-link" style="margin-right: 15px;"
|
||||
href="<?= $escaper->escapeUrl($block->getImageUrl($author['image'], 'auth')) ?>">
|
||||
<img src="<?= $escaper->escapeUrl($block->getImageUrl($author['image'], 'auth')) ?>"
|
||||
id="post_image_image"
|
||||
title="<?= $escaper->escapeHtmlAttr($author['image']) ?>"
|
||||
alt="<?= $escaper->escapeHtmlAttr($author['image']) ?>" height="70" width="70"
|
||||
class="small-image-preview v-middle">
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<input type="file" name="image" id="image" value="<?= $escaper->escapeHtml($author['image']) ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Avatar')) ?>"
|
||||
class="input-file"
|
||||
style="width: 90%;position: relative;top: -5px">
|
||||
<?php if (!empty($author['image'])) : ?>
|
||||
<span class="delete-image" style="display: inline-flex;">
|
||||
<input type="checkbox" name="image[delete]" value="1" class="checkbox"
|
||||
id="post_image_delete">
|
||||
<label for="post_image_delete"> Delete Image</label>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label for="url_key" class="label"><span><?= $escaper->escapeHtml(__('URL Key')) ?></span></label>
|
||||
<div class="control">
|
||||
<input type="text" name="url_key" id="url_key" value="<?= $escaper->escapeHtmlAttr($author['url_key']) ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('URL Key')) ?>"
|
||||
class="input-text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label for="full_url" class="label"><span><?= $escaper->escapeHtml(__('Full URL')) ?></span></label>
|
||||
<div class="control">
|
||||
<span class="mp_full_url">
|
||||
<?= $escaper->escapeHtml($block->getUrl("blog/author")
|
||||
. $author['url_key'] . $block->getUrlSuffix()) ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label for="facebook_link" class="label"><span><?= $escaper->escapeHtml(__('Facebook Link')) ?></span></label>
|
||||
<div class="control">
|
||||
<input type="url" name="facebook_link" id="facebook_link"
|
||||
value="<?= $escaper->escapeHtml($author['facebook_link']) ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Facebook Link')) ?>" class="input-text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label for="twitter_link" class="label"><span><?= $escaper->escapeHtml(__('Twitter Link')) ?></span></label>
|
||||
<div class="control">
|
||||
<input type="url" name="twitter_link" id="twitter_link"
|
||||
value="<?= $escaper->escapeHtmlAttr($author['twitter_link']) ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Twitter Link')) ?>" class="input-text">
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="actions-toolbar">
|
||||
<div class="primary">
|
||||
<button type="submit" class="action submit primary"
|
||||
title="<?= /* @noEscape */
|
||||
$author['name'] === '' ? __('Submit') : __('Save') ?>">
|
||||
<span>
|
||||
<?= /* @noEscape */
|
||||
$author['name'] === '' ? __('Submit') : __('Save') ?>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<style>
|
||||
.mp-field {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.mp-field .control {
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.mp-field .control .delete-image {
|
||||
width: 65%;
|
||||
}
|
||||
|
||||
.mp-field .label {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.sidebar.sidebar-main:before {
|
||||
content: unset !important;
|
||||
}
|
||||
#maincontent h1 {
|
||||
font-weight: 300;
|
||||
line-height: 1.1;
|
||||
font-size: 2.6rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
#maincontent h2 {
|
||||
font-weight: 300;
|
||||
line-height: 1.1;
|
||||
font-size: 1.8rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
#maincontent h3 {
|
||||
font-weight: 600;
|
||||
line-height: 1.1;
|
||||
font-size: 1.8rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
#maincontent h4 {
|
||||
font-weight: 700;
|
||||
line-height: 1.1;
|
||||
font-size: 1.4rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
#maincontent h5 {
|
||||
font-weight: 700;
|
||||
line-height: 1.1;
|
||||
font-size: 1.2rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
#maincontent p {
|
||||
margin-top: 0rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
.ck-editor__editable {min-height: 300px;}
|
||||
</style>
|
||||
|
||||
|
||||
<script>
|
||||
CKEDITOR.ClassicEditor.create(document.getElementById("short_description"), {
|
||||
toolbar: {
|
||||
items: [
|
||||
'undo', 'redo', '|',
|
||||
'heading', '|',
|
||||
'bold', 'italic', 'strikethrough', 'underline', 'code', 'subscript', 'superscript', 'removeFormat', '|',
|
||||
'bulletedList', 'numberedList', 'todoList', '|',
|
||||
'alignment:left', 'alignment:right', 'alignment:center', 'alignment:justify', '|',
|
||||
'blockQuote', '|',
|
||||
'outdent', 'indent',
|
||||
],
|
||||
shouldNotGroupWhenFull: true
|
||||
},
|
||||
list: {
|
||||
properties: {
|
||||
styles: true,
|
||||
startIndex: true,
|
||||
reversed: true
|
||||
}
|
||||
},
|
||||
heading: {
|
||||
options: [
|
||||
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
|
||||
{ model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
|
||||
{ model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
|
||||
{ model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
|
||||
{ model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' },
|
||||
{ model: 'heading5', view: 'h5', title: 'Heading 5', class: 'ck-heading_heading5' },
|
||||
{ model: 'heading6', view: 'h6', title: 'Heading 6', class: 'ck-heading_heading6' }
|
||||
]
|
||||
},
|
||||
placeholder: '',
|
||||
removePlugins: [
|
||||
'AIAssistant',
|
||||
'CKBox',
|
||||
'CKFinder',
|
||||
'EasyImage',
|
||||
'RealTimeCollaborativeComments',
|
||||
'RealTimeCollaborativeTrackChanges',
|
||||
'RealTimeCollaborativeRevisionHistory',
|
||||
'PresenceList',
|
||||
'Comments',
|
||||
'TrackChanges',
|
||||
'TrackChangesData',
|
||||
'RevisionHistory',
|
||||
'Pagination',
|
||||
'WProofreader',
|
||||
'MathType',
|
||||
'SlashCommand',
|
||||
'Template',
|
||||
'DocumentOutline',
|
||||
'FormatPainter',
|
||||
'TableOfContents',
|
||||
'PasteFromOfficeEnhanced'
|
||||
]
|
||||
}).then( editor => {
|
||||
window.editor = editor;
|
||||
} ).catch( err => {
|
||||
console.error( err.stack );
|
||||
} );
|
||||
</script>
|
||||
@@ -0,0 +1,94 @@
|
||||
<?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\Category\Widget;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var Widget $block */
|
||||
/** @var Escaper $escaper */
|
||||
$tree = $block->getTree();
|
||||
if ($tree) : ?>
|
||||
<div class="mp-sidebar mpcss">
|
||||
<div class="row">
|
||||
<div class="block-title col-xs-12 sidebar-categories">
|
||||
<p class="block-mp-sidebar-heading" role="heading" aria-label="2"><?= $escaper->escapeHtml(__('Categories')) ?></p>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<?= $block->getCategoryTreeHtml($tree) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var parentCategory = document.querySelector(".mp-blog-expand-tree-2");
|
||||
var childCategory = document.querySelector(".mp-blog-expand-tree-3");
|
||||
if(parentCategory) {
|
||||
parentCategory.addEventListener('click', function (e) {
|
||||
var level3 = this.parentElement.querySelector(".category-level3");
|
||||
if (this.classList.contains("mp-blog-expand-tree-2")) {
|
||||
if(level3) {
|
||||
level3.style.display = "block";
|
||||
}
|
||||
this.classList.remove("mp-blog-expand-tree-2", "fa", "fa-plus-square-o");
|
||||
this.classList.add("mp-blog-narrow-tree-2", "fa", "fa-minus-square-o");
|
||||
} else {
|
||||
var level4 = this.parentElement.querySelector(".category-level4");
|
||||
if(level4) {
|
||||
level4.style.display = "none";
|
||||
}
|
||||
if(level3) {
|
||||
level3.style.display = "none";
|
||||
}
|
||||
this.classList.remove("mp-blog-narrow-tree-2", "fa", "fa-minus-square-o");
|
||||
this.classList.add("mp-blog-expand-tree-2", "fa", "fa-plus-square-o");
|
||||
if(this.parentElement.querySelector(".mp-blog-narrow-tree-3")) {
|
||||
this.parentElement.querySelector(".mp-blog-narrow-tree-3")
|
||||
.classList.remove("mp-blog-narrow-tree-3", "fa", "fa-minus-square-o");
|
||||
this.parentElement.querySelector(".mp-blog-narrow-tree-3")
|
||||
.classList.add("mp-blog-expand-tree-3", "fa", "fa-plus-square-o");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(childCategory) {
|
||||
childCategory.addEventListener('click', function (e) {
|
||||
var level4 = this.parentElement.querySelector(".category-level4");
|
||||
if (this.classList.contains("mp-blog-expand-tree-3")) {
|
||||
if(level4) {
|
||||
level4.style.display = "block";
|
||||
}
|
||||
this.classList.remove("mp-blog-expand-tree-3", "fa", "fa-plus-square-o");
|
||||
this.classList.add("mp-blog-narrow-tree-3", "fa", "fa-minus-square-o");
|
||||
} else {
|
||||
if(level4) {
|
||||
level4.style.display = "none";
|
||||
}
|
||||
this.classList.remove("mp-blog-narrow-tree-3", "fa", "fa-minus-square-o");
|
||||
this.classList.add("mp-blog-expand-tree-3", "fa", "fa-plus-square-o");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,206 @@
|
||||
<?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\Design;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var Design $block */
|
||||
/** @var Escaper $escaper */
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var body = document.body;
|
||||
window.addEventListener('load', function () {
|
||||
if (body.classList.contains('page-layout-1column')) {
|
||||
var columns = document.querySelector('.columns');
|
||||
var sidebarMain = columns.querySelector('.sidebar.sidebar-main');
|
||||
if (sidebarMain) {
|
||||
columns.removeChild(sidebarMain);
|
||||
}
|
||||
}
|
||||
var currentTheme = "<?php echo /** @noEscape */ $block->getCurrentTheme() ?>";
|
||||
if (currentTheme === "Etheme/yourstore") {
|
||||
body.classList.add('mpblog-etheme-yourstore');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php $color = $block->getHelper()->getDisplayConfig('font_color');
|
||||
?>
|
||||
<style type="text/css">
|
||||
.mp-blog-review-title {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#mp-blog-review {
|
||||
position: relative;
|
||||
height: 65px;
|
||||
}
|
||||
|
||||
#mp-blog-review div {
|
||||
padding: 10px 20px;
|
||||
color: #ffffff;
|
||||
cursor: pointer;
|
||||
width: 120px;
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.mp-blog-like {
|
||||
background-color: #6AA84F;
|
||||
left: 33%;
|
||||
}
|
||||
|
||||
.mp-blog-dislike {
|
||||
background-color: #EC3A3C;
|
||||
left: 52%;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.mp-blog-like {
|
||||
left: 28%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.mp-blog-like {
|
||||
left: 20%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 375px) {
|
||||
.mp-blog-like {
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.mp-blog-new-post {
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.mp-blog-new-post button {
|
||||
float: right;
|
||||
margin: 10px;
|
||||
padding: 8px 15px
|
||||
}
|
||||
|
||||
.post-item-wraper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.post-info-action {
|
||||
display: flex;
|
||||
position: absolute;
|
||||
float: right;
|
||||
right: 10px;
|
||||
top: 10px;
|
||||
}
|
||||
|
||||
.post-info-action div {
|
||||
margin: 0 10px;
|
||||
width: 25px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#mpblog-list-container a {
|
||||
text-decoration: none;
|
||||
}
|
||||
#mpblog-list-container a.mp-read-more{
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.post-view-image {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/*Post List Content Css*/
|
||||
.post-info-wraper h2.mp-post-title a,
|
||||
.about-admin h4.admin-title a,
|
||||
.mp-post-meta-info a.mp-read-more,
|
||||
.mp-post-info a.mp-info,
|
||||
ul.menu-categories a.list-categories:hover,
|
||||
.products-same-post a.product-item-link:hover,
|
||||
a.mp-relate-link,
|
||||
.mpblog-product-name {
|
||||
color: <?= /** @noEscape */ $color ?> !important;
|
||||
}
|
||||
|
||||
a.label.label-default.tags-list:hover,
|
||||
a.label.label-default.tags-list:focus {
|
||||
background: <?= /** @noEscape */ $color ?>;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.list-post-tabs a {
|
||||
background: #fbfbfb;
|
||||
color: <?= /** @noEscape */ $color ?>;
|
||||
}
|
||||
|
||||
/*Site Map CSS*/
|
||||
.mp-sidebar a.sitemap-link,
|
||||
.menu-archives a.list-archives:hover {
|
||||
text-decoration: none !important;
|
||||
color: <?= /** @noEscape */ $color ?> !important;
|
||||
}
|
||||
|
||||
.mp-sidebar .row div {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/*Comment CSS*/
|
||||
button.default-cmt__content__cmt-block__cmt-box__cmt-btn__btn-submit {
|
||||
background: <?= /** @noEscape */ $color ?> !important;
|
||||
color: #fff;
|
||||
border-color: #999 !important;
|
||||
}
|
||||
|
||||
span.cmt-row__cmt-username {
|
||||
font-weight: 600;
|
||||
color: <?= /** @noEscape */ $color ?>;
|
||||
}
|
||||
|
||||
a.interactions__btn-actions.mpblog-like {
|
||||
color: #333333
|
||||
}
|
||||
|
||||
a.interactions__btn-actions.mpblog-liked {
|
||||
color: <?= /** @noEscape */ $color ?>;
|
||||
}
|
||||
|
||||
a.interactions__btn-actions {
|
||||
color: <?= /** @noEscape */ $color ?>;
|
||||
|
||||
}
|
||||
|
||||
/*Widget CSS*/
|
||||
.widget-title a {
|
||||
color: <?= /** @noEscape */ $color ?>;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
/*Author CSS*/
|
||||
.author-name h3 {
|
||||
color: <?= /** @noEscape */ $color ?>;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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\Html\Footer;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var Footer $block */
|
||||
/** @var Escaper $escaper */
|
||||
$helper = $block->getHelperData();
|
||||
?>
|
||||
<?php if ($helper->isEnabled()) : ?>
|
||||
<?php if ($helper->getBlogConfig('display/footer')) : ?>
|
||||
<li class="mt-4">
|
||||
<a class="text-base leading-6" <?= /** @noEscape */
|
||||
$block->getLinkAttributes() ?>>
|
||||
<?= $escaper->escapeHtml($block->getLabel()); ?>
|
||||
<?= ($block->getCounter()) ? '<span>' . $escaper->escapeHtml($block->getCounter()) . '</span>' : ''; ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* Hyvä Themes - https://hyva.io
|
||||
* Copyright © Hyvä Themes 2020-present. All rights reserved.
|
||||
* This product is licensed per Magento install
|
||||
* See https://hyva.io/license
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Hyva\Theme\Model\ViewModelRegistry;
|
||||
use Hyva\Theme\ViewModel\Customer;
|
||||
use Hyva\Theme\ViewModel\StoreConfig;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\View\Element\Template;
|
||||
|
||||
/** @var Template $block */
|
||||
/** @var Escaper $escaper */
|
||||
/** @var ViewModelRegistry $viewModels */
|
||||
|
||||
/** @var Customer $customer */
|
||||
$customer = $viewModels->require(Customer::class);
|
||||
/** @var StoreConfig $storeConfig */
|
||||
$storeConfig = $viewModels->require(StoreConfig::class);
|
||||
?>
|
||||
<div class="md:w-1/2 w-full flex flex-wrap pr-4">
|
||||
<div class="w-full grid grid-cols-1 sm:grid-cols-2 gap-8 xl:col-span-2">
|
||||
<div>
|
||||
<h2 class="text-md leading-5 font-semibold tracking-wider uppercase">
|
||||
Company
|
||||
</h2>
|
||||
<ul class="mt-4">
|
||||
<li>
|
||||
<a href="#" class="text-base leading-6">
|
||||
About
|
||||
</a>
|
||||
</li>
|
||||
<li class="mt-4">
|
||||
<a href="<?= $escaper->escapeUrl($block->getUrl('customer/account')) ?>"
|
||||
class="text-base leading-6">
|
||||
<?= $escaper->escapeHtml(__('My Account')) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php if (!$customer->customerLoggedIn()): ?>
|
||||
<li class="mt-4">
|
||||
<a href="<?= $escaper->escapeUrl($block->getUrl('sales/guest/form')) ?>"
|
||||
class="text-base leading-6">
|
||||
<?= $escaper->escapeHtml(__('Orders and Returns')) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php if ($storeConfig->getStoreConfig('catalog/seo/search_terms')): ?>
|
||||
<li class="mt-4">
|
||||
<a href="<?= $escaper->escapeUrl($block->getUrl('search/term/popular')) ?>"
|
||||
class="text-base leading-6">
|
||||
<?= $escaper->escapeHtml(__('Search Terms')) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<li class="mt-4 mb-4">
|
||||
<a href="<?= $escaper->escapeUrl($block->getUrl('contact')) ?>"
|
||||
class="text-base leading-6">
|
||||
<?= $escaper->escapeHtml(__('Contact')) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?= $block->getChildHtml() ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-md leading-5 font-semibold tracking-wider uppercase">
|
||||
Legal
|
||||
</h2>
|
||||
<ul class="mt-4">
|
||||
<li class="mt-4">
|
||||
<a href="#" class="text-base leading-6">
|
||||
Privacy
|
||||
</a>
|
||||
</li>
|
||||
<li class="mt-4">
|
||||
<a href="#" class="text-base leading-6">
|
||||
Terms and Conditions
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+335
@@ -0,0 +1,335 @@
|
||||
<?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\Post\AuthorPost;
|
||||
use Mageplaza\Blog\Model\Post;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var AuthorPost $block */
|
||||
/** @var Escaper $escaper */
|
||||
$postCollection = $block->getPostCollection();
|
||||
$modalViewModel = $viewModels->require(\Hyva\Theme\ViewModel\Modal::class);
|
||||
$postDatas = $block->getPostDatas($postCollection);
|
||||
$jsonData = json_encode($postDatas);
|
||||
|
||||
?>
|
||||
<?php if (!$block->getAuthorStatus()) : ?>
|
||||
<div>
|
||||
<h3><?= $escaper->escapeHtml(__('Your account must be licensed in order to perform the Post creation and management function')) ?></h3>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="mp-blog-new-post" x-data="{
|
||||
...hyva.modal(),
|
||||
init() {
|
||||
window.openDialogNewPost = function (event) {
|
||||
this.show('add-new-post-name', event);
|
||||
}.bind(this);
|
||||
window.hideMyDialogNewPost = function (event) {
|
||||
this.hide('add-new-post-name', event);
|
||||
|
||||
}.bind(this);
|
||||
|
||||
|
||||
}
|
||||
}" x-init="init()">
|
||||
<button onclick="handleAddPost()" type="button" aria-haspopup="dialog"
|
||||
class="action primary btn btn-primary" title="<?= $escaper->escapeHtmlAttr(__('Add New Post')) ?>">
|
||||
<?= $escaper->escapeHtml(__('Add New Post')) ?>
|
||||
</button>
|
||||
<?= /** @noEscape */ $modalViewModel->createModal()
|
||||
->addDialogClass('overflow-y-hidden overflow-x-hidden fixed z-50 justify-center items-center w-3/4 md:inset-0 h-4/5')
|
||||
->removeDialogClass('p-10')
|
||||
->withDialogRefName("add-new-post-name")
|
||||
->withContent(<<<HTML
|
||||
<div id="mp-blog-new-post-popup">
|
||||
<header class="modal-header mb-3">
|
||||
<h3 id="popup_author_post" class="modal-title text-3xl border-b p-4" data-role="title">Add New Post</h3>
|
||||
</header>
|
||||
{$block->getChildHtml('mpblog_manage_post')}
|
||||
</div>
|
||||
HTML
|
||||
) ?>
|
||||
|
||||
</div>
|
||||
<div class="post-list-content" id="mpblog-list-container">
|
||||
<?php if ($postCollection && count($postCollection) > 0) : ?>
|
||||
<div class="post-list-body">
|
||||
<?php $i = 1 ?>
|
||||
<?php /** @var Post $post */
|
||||
foreach ($postCollection as $post) : ?>
|
||||
<div data-post-id="<?= $escaper->escapeHtml($post->getId()); ?>"
|
||||
class="post-list-item col-mp post-item-list mp-12">
|
||||
<div class="post-item-wraper">
|
||||
<?= /* @noEscape */
|
||||
$block->getStatusHtmlById($post->getEnabled()) ?>
|
||||
<?php if ($post->getImage()) : ?>
|
||||
<div class="post-image">
|
||||
<a href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<img class="img-responsive"
|
||||
src="<?= $escaper->escapeUrl($block->resizeImage($post->getImage(),
|
||||
'400x')) ?>"
|
||||
alt="<?= $escaper->escapeHtmlAttr($post->getName()) ?>"/>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="post-info-wraper">
|
||||
<h2 class="mp-post-title">
|
||||
<a class="post-link-title" title="<?= $escaper->escapeHtml($post->getName()); ?>"
|
||||
href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<?= $escaper->escapeHtml($post->getName()) ?>
|
||||
</a>
|
||||
</h2>
|
||||
<div class="mp-post-info">
|
||||
<?= /* @noEscape */
|
||||
$block->getPostInfo($post) ?>
|
||||
</div>
|
||||
<div class="post-short-description">
|
||||
<p>
|
||||
<?= /* @noEscape */
|
||||
$block->maxShortDescription($post->getShortDescription()) ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="mp-clearfix"></div>
|
||||
<div class="mp-post-meta-info mp-alignright">
|
||||
<div class="actions">
|
||||
<a class="mp-read-more" href="<?= $escaper->escapeUrl($post->getUrl()) ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Read More')) ?>">
|
||||
<?= $escaper->escapeHtml(__('Read More')) ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="post-info-action" data-postId="<?= $escaper->escapeHtml($post->getId()); ?>">
|
||||
<div class="mpblog-post-duplicate"
|
||||
onclick='handleDuplicate(this,<?= /** @noEscape */ $post->getId() ?>, "<?= /** @noEscape */ $post->getImage() ?>")'
|
||||
>
|
||||
<img
|
||||
src="<?= $escaper->escapeUrl($block->getViewFileUrl('Mageplaza_Blog::media/images/duplicate.svg')) ?>"
|
||||
align="middle"
|
||||
alt="<?= $escaper->escapeHtmlAttr(__('Duplicate')); ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Duplicate')) ?>"
|
||||
/>
|
||||
</div>
|
||||
<div class="mpblog-post-edit"
|
||||
onclick='handleEdit(this,<?= /** @noEscape */ $post->getId() ?>, "<?= /** @noEscape */ $post->getImage() ?>")'
|
||||
>
|
||||
<img src="<?= $escaper->escapeUrl($block->getViewFileUrl('Mageplaza_Blog::media/images/writing.svg')) ?>"
|
||||
align="middle"
|
||||
alt="<?= $escaper->escapeHtmlAttr(__('Edit')); ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Edit')) ?>"
|
||||
/>
|
||||
</div>
|
||||
<div class="mpblog-post-delete" onclick="handleDelete(this)">
|
||||
<img src="<?= $escaper->escapeUrl($block->getViewFileUrl('Mageplaza_Blog::media/images/delete.svg')) ?>"
|
||||
align="middle"
|
||||
alt="<?= $escaper->escapeHtmlAttr(__('Delete')) ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Delete')) ?>"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $i++; ?>
|
||||
<?php if ($i % 2 == 0) : ?>
|
||||
<div class="mp-clear"></div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<div class="mp-clear"></div>
|
||||
</div>
|
||||
<?= $block->getPagerHtml() ?>
|
||||
<?php else : ?>
|
||||
<?= $escaper->escapeHtml(__('There are no posts at this moment')) ?>
|
||||
<?php endif; ?>
|
||||
<?= /* @noEscape */
|
||||
$block->getChildHtml('additional') ?>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
let pubUrl = "<?= $escaper->escapeHtml($block->getBaseMediaUrl()) ?>";
|
||||
let title = document.querySelector('#popup_author_post');
|
||||
let name = document.querySelector('#name');
|
||||
let post_id = document.querySelector('#post_id');
|
||||
let short_description = document.querySelector('#short_description');
|
||||
let allow_comment = document.querySelector('#allow_comment');
|
||||
let publish_date = document.querySelector('#publish_date');
|
||||
|
||||
function handleDelete (element) {
|
||||
var postId = element.closest('.post-info-action').getAttribute('data-postId');
|
||||
fetch("<?= $escaper->escapeHtml($block->getUrl('mpblog/post/deletepost')) ?>", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
post_id: postId
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.status === 1) {
|
||||
var postListItem = document.querySelector('.post-list-item[data-post-id="' + result.post_id + '"]');
|
||||
if (postListItem) {
|
||||
postListItem.remove();
|
||||
const reloadCustomerDataEvent = new CustomEvent("reload-customer-section-data");
|
||||
window.dispatchEvent(reloadCustomerDataEvent);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
// open modal add new post
|
||||
function handleAddPost () {
|
||||
resetFormModal();
|
||||
title.innerText = 'Add New Post';
|
||||
openDialogNewPost();
|
||||
}
|
||||
// open modal edit new post
|
||||
function handleEdit (e, post_id, image) {
|
||||
resetFormModal();
|
||||
let listData = <?php echo /** @noEscape */ json_decode($jsonData) ?>;
|
||||
let dataSelect = listData[post_id];
|
||||
name.value = dataSelect?.name;
|
||||
post_id.value = dataSelect?.post_id;
|
||||
short_description.value = dataSelect?.short_description;
|
||||
editor.setData(dataSelect?.post_content ?? "");
|
||||
allow_comment.value = dataSelect?.allow_comment;
|
||||
publish_date.value = convertDateToDisplay(dataSelect?.publish_date);
|
||||
treeselectCategories.updateValue(dataSelect?.category_ids);
|
||||
|
||||
treeselectTags.updateValue(dataSelect?.tag_ids);
|
||||
treeselectTopics.updateValue(dataSelect?.topic_ids);
|
||||
addPreviewImg(image);
|
||||
|
||||
title.innerText = 'Edit Post';
|
||||
openDialogNewPost()
|
||||
}
|
||||
// open modal duplicate new post
|
||||
function handleDuplicate (e, post_id, image) {
|
||||
resetFormModal();
|
||||
let listData = <?php echo /** @noEscape */ json_decode($jsonData) ?>;
|
||||
let dataSelect = listData[post_id];
|
||||
name.value = dataSelect?.name;
|
||||
short_description.value = dataSelect?.short_description;
|
||||
editor.setData(dataSelect?.post_content ?? "");
|
||||
allow_comment.value = dataSelect?.allow_comment;
|
||||
publish_date.value = convertDateToDisplay(dataSelect?.publish_date);
|
||||
treeselectCategories.updateValue(dataSelect?.category_ids);
|
||||
treeselectTags.updateValue(dataSelect?.tag_ids);
|
||||
treeselectTopics.updateValue(dataSelect?.topic_ids);
|
||||
addPreviewImg(image);
|
||||
title.innerText = 'Duplicate Post';
|
||||
openDialogNewPost()
|
||||
}
|
||||
// reset data when hide modal
|
||||
function resetFormModal () {
|
||||
name.value = '';
|
||||
post_id.value = '';
|
||||
short_description.value = '';
|
||||
editor.setData("");
|
||||
allow_comment.value = 0;
|
||||
publish_date.value = '';
|
||||
treeselectCategories.updateValue([]);
|
||||
treeselectTags.updateValue([]);
|
||||
treeselectTopics.updateValue([]);
|
||||
var element = document.querySelector('.mp-image-link');
|
||||
if (element) {
|
||||
element.parentNode.removeChild(element);
|
||||
}
|
||||
let messagesError = document.querySelectorAll('#mp-blog-new-post-popup form .messages');
|
||||
messagesError.forEach(mess => {
|
||||
mess.remove()
|
||||
})
|
||||
}
|
||||
// add preview image when open modal edit and duplicate modal
|
||||
function addPreviewImg (value) {
|
||||
if (value) {
|
||||
const imageEl = document.getElementById("image")?.parentElement;
|
||||
var linkElement = document.createElement('a');
|
||||
linkElement.className = 'mp-image-link';
|
||||
linkElement.style = "margin-right: 15px";
|
||||
linkElement.href = pubUrl + 'mageplaza/blog/post/' + value;
|
||||
linkElement.onclick = function () {
|
||||
imagePreview('post_image_image');
|
||||
return false;
|
||||
};
|
||||
var imageElement = document.createElement('img');
|
||||
imageElement.src = pubUrl + 'mageplaza/blog/post/' + value;
|
||||
imageElement.id = 'post_image_image';
|
||||
imageElement.title = value;
|
||||
imageElement.alt = value;
|
||||
imageElement.height = 40;
|
||||
imageElement.width = 40;
|
||||
imageElement.className = 'small-image-preview v-middle';
|
||||
linkElement.appendChild(imageElement);
|
||||
if (imageEl) {
|
||||
imageEl.insertBefore(linkElement, imageEl.children[0]);
|
||||
}
|
||||
var deleteSpan = document.createElement('span');
|
||||
deleteSpan.className = 'delete-image';
|
||||
deleteSpan.style.display = 'inline-flex';
|
||||
var deleteInput = document.createElement('input');
|
||||
deleteInput.type = 'checkbox';
|
||||
deleteInput.name = 'image[delete]';
|
||||
deleteInput.value = '1';
|
||||
deleteInput.className = 'checkbox';
|
||||
deleteInput.id = 'post_image_delete';
|
||||
|
||||
var deleteLabel = document.createElement('label');
|
||||
deleteLabel.htmlFor = 'post_image_delete';
|
||||
deleteLabel.textContent = 'Delete Image';
|
||||
|
||||
deleteSpan.appendChild(deleteInput);
|
||||
deleteSpan.appendChild(deleteLabel);
|
||||
if (!imageEl.querySelector('.delete-image')) {
|
||||
imageEl.appendChild(deleteSpan);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// convert date in modal
|
||||
function convertDateToSave (publicDateValue) {
|
||||
var inputDate = new Date(publicDateValue);
|
||||
var formattedDate = ("0" + (inputDate.getMonth() + 1)).slice(-2) + '/' +
|
||||
("0" + inputDate.getDate()).slice(-2) + '/' +
|
||||
inputDate.getFullYear() + ' ' +
|
||||
("0" + inputDate.getHours()).slice(-2) + ':' +
|
||||
("0" + inputDate.getMinutes()).slice(-2) + ':' +
|
||||
("0" + inputDate.getSeconds()).slice(-2);
|
||||
return formattedDate
|
||||
}
|
||||
|
||||
function convertDateToDisplay (dateString) {
|
||||
var currentDate = new Date(dateString);
|
||||
var year = currentDate.getFullYear();
|
||||
var month = ('0' + (currentDate.getMonth() + 1)).slice(-2);
|
||||
var day = ('0' + currentDate.getDate()).slice(-2);
|
||||
var hours = ('0' + currentDate.getHours()).slice(-2);
|
||||
var minutes = ('0' + currentDate.getMinutes()).slice(-2);
|
||||
var formattedDateTime = year + '-' + month + '-' + day + 'T' + hours + ':' + minutes;
|
||||
return formattedDateTime;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
+336
@@ -0,0 +1,336 @@
|
||||
<?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\Post\ManagePost;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var ManagePost $block */
|
||||
/** @var Escaper $escaper */
|
||||
?>
|
||||
<button title="Close (Esc)" type="button" class="mfp-close" style="position: absolute;top: -5px;right: 10px;font-size: 25px;" onclick="hideMyDialogNewPost()">×</button>
|
||||
<form enctype="multipart/form-data" data-mage-init='{"validation": {}}'
|
||||
action="<?= $escaper->escapeHtml($block->getUrl('mpblog/post/manage')) ?>" method="post" class="form"
|
||||
name="mp_blog_post_form" id="mp_blog_post_form"
|
||||
style="overflow-y: auto; height: 700px"
|
||||
x-data="Object.assign(hyva.formValidation($el), initAddNewPost())"
|
||||
@submit.prevent="submitForm();"
|
||||
>
|
||||
<?= /* @noEscape */ $block->getBlockHtml('formkey'); ?>
|
||||
<fieldset class="fieldset">
|
||||
<div class="field required mp-field">
|
||||
<label for="name" class="label">
|
||||
<span>
|
||||
<b><?= $escaper->escapeHtml(__('Post Name')) ?></b>
|
||||
</span></label>
|
||||
<div class="control">
|
||||
<input type="text" name="name" id="name" title="<?= $escaper->escapeHtmlAttr(__('Post Name')) ?>"
|
||||
class="input-text" data-validate='{"required": true}'>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="post_id" id="post_id">
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<b for="short_description" class="label">
|
||||
<span><?= $escaper->escapeHtml(__('Short Description')) ?></span>
|
||||
</b>
|
||||
<div class="control">
|
||||
<textarea name="short_description" id="short_description" rows="5" cols="19" class="w-full"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<b for="post_content" class="label">
|
||||
<span><?= $escaper->escapeHtml(__('Post Content')) ?></span>
|
||||
</b>
|
||||
<div class="control">
|
||||
<textarea name="post_content" id="post_content" class="post_content_hyva" rows="5" cols="19">
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label for="image" class="label"><b><?= $escaper->escapeHtml(__('Image')) ?></b></label>
|
||||
<div class="control" style="display: flex">
|
||||
<input type="file" name="image" id="image" title="<?= $escaper->escapeHtmlAttr(__('Image')) ?>"
|
||||
class="input-file">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mp-custom">
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label class="label"><span><?= $escaper->escapeHtml(__('Select Category')) ?></span></label>
|
||||
<div data-bind="scope: 'customCategory'">
|
||||
<div id="categories_ids"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label class="label"><span><?= $escaper->escapeHtml(__('Select Topic')) ?></span></label>
|
||||
<div data-bind="scope: 'customTopic'">
|
||||
<div id="topics_ids"></div>
|
||||
<!-- ko template: getTemplate() --><!-- /ko -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label class="label"><span><?= $escaper->escapeHtml(__('Select Tag')) ?></span></label>
|
||||
<div data-bind="scope: 'customTag'">
|
||||
<div id="tags_ids"></div>
|
||||
<!-- ko template: getTemplate() --><!-- /ko -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label for="allow_comment" class="label"><b><?= $escaper->escapeHtml(__('Allow Comment')) ?></b></label>
|
||||
<div class="control">
|
||||
<select id="allow_comment" name="allow_comment" class="w-full">
|
||||
<option value="0"><span><?= $escaper->escapeHtml(__('No')) ?></option>
|
||||
<option value="1"><span><?= $escaper->escapeHtml(__('Yes')) ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mp-field" style="margin-top: 1.5rem">
|
||||
<label for="publish_date" class="label"><b><?= $escaper->escapeHtml(__('Publish Date')) ?></b></label>
|
||||
<div class="control">
|
||||
<input name="publish_date" id="publish_date" type="datetime-local">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?= $block->getChildHtml('field_additional') ?>
|
||||
</fieldset>
|
||||
<div class="actions-toolbar">
|
||||
<div class="primary">
|
||||
<button type="submit" class="action submit primary mpblog-action-new"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Save')) ?>">
|
||||
<span><?= $escaper->escapeHtml(__('Save')) ?></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($block->checkTheme()) : ?>
|
||||
<style>
|
||||
.admin__action-multiselect-crumb .action-close:before {
|
||||
top: -6px;
|
||||
right: 8px;
|
||||
}
|
||||
|
||||
.admin__action-multiselect-menu-inner-item._root .action-menu-item .admin__action-multiselect-label:before {
|
||||
content: '\f846';
|
||||
font-family: 'porto-icons';
|
||||
}
|
||||
|
||||
.admin__action-multiselect-dropdown:before {
|
||||
content: '\f803';
|
||||
font-family: 'porto-icons';
|
||||
}
|
||||
|
||||
.admin__action-multiselect-tree .action-menu-item._expended .admin__action-multiselect-dropdown:before {
|
||||
right: 5px;
|
||||
position: absolute;
|
||||
content: '\f800';
|
||||
font-family: 'porto-icons';
|
||||
}
|
||||
|
||||
</style>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
<style>
|
||||
.ck-editor__editable {min-height: 300px;}
|
||||
</style>
|
||||
<script>
|
||||
CKEDITOR.ClassicEditor.create(document.getElementById("post_content"), {
|
||||
toolbar: {
|
||||
items: [
|
||||
'undo', 'redo', '|',
|
||||
'heading', '|',
|
||||
'bold', 'italic', 'strikethrough', 'underline', 'code', 'subscript', 'superscript', 'removeFormat', '|',
|
||||
'bulletedList', 'numberedList', 'todoList', '|',
|
||||
'alignment:left', 'alignment:right', 'alignment:center', 'alignment:justify', '|',
|
||||
'blockQuote', '|',
|
||||
'outdent', 'indent'
|
||||
],
|
||||
shouldNotGroupWhenFull: true
|
||||
},
|
||||
list: {
|
||||
properties: {
|
||||
styles: true,
|
||||
startIndex: true,
|
||||
reversed: true
|
||||
}
|
||||
},
|
||||
heading: {
|
||||
options: [
|
||||
{model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph'},
|
||||
{model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1'},
|
||||
{model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2'},
|
||||
{model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3'},
|
||||
{model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4'},
|
||||
{model: 'heading5', view: 'h5', title: 'Heading 5', class: 'ck-heading_heading5'},
|
||||
{model: 'heading6', view: 'h6', title: 'Heading 6', class: 'ck-heading_heading6'}
|
||||
]
|
||||
},
|
||||
placeholder: '',
|
||||
removePlugins: [
|
||||
'AIAssistant',
|
||||
'CKBox',
|
||||
'CKFinder',
|
||||
'EasyImage',
|
||||
'RealTimeCollaborativeComments',
|
||||
'RealTimeCollaborativeTrackChanges',
|
||||
'RealTimeCollaborativeRevisionHistory',
|
||||
'PresenceList',
|
||||
'Comments',
|
||||
'TrackChanges',
|
||||
'TrackChangesData',
|
||||
'RevisionHistory',
|
||||
'Pagination',
|
||||
'WProofreader',
|
||||
'MathType',
|
||||
'SlashCommand',
|
||||
'Template',
|
||||
'DocumentOutline',
|
||||
'FormatPainter',
|
||||
'TableOfContents',
|
||||
'PasteFromOfficeEnhanced'
|
||||
]
|
||||
}).then(editor => {
|
||||
window.editor = editor;
|
||||
}).catch(err => {
|
||||
console.error(err.stack);
|
||||
});
|
||||
|
||||
const categories = <?php echo /** @noEscape */ ($block->getCategoriesTree()) ?>;
|
||||
const topics = <?php echo /** @noEscape */ ($block->getTopicTree()) ?>;
|
||||
const tags = <?php echo /** @noEscape */ ($block->getTagTree()) ?>;
|
||||
const optionsCategories = categories?.map(data => {
|
||||
return {
|
||||
name: data?.label,
|
||||
value: data?.value
|
||||
}
|
||||
});
|
||||
const optionsTopics = Object.values(topics)?.map(data => {
|
||||
return {
|
||||
name: data?.label,
|
||||
value: data?.value
|
||||
}
|
||||
});
|
||||
const optionsTags = Object.values(tags)?.map(data => {
|
||||
return {
|
||||
name: data?.label,
|
||||
value: data?.value
|
||||
}
|
||||
});
|
||||
const domElementCategories = document.querySelector('#categories_ids');
|
||||
const treeselectCategories = new Treeselect({
|
||||
parentHtmlContainer: domElementCategories,
|
||||
options: optionsCategories,
|
||||
value: []
|
||||
|
||||
});
|
||||
const domElementTopics = document.querySelector('#topics_ids');
|
||||
const treeselectTopics = new Treeselect({
|
||||
parentHtmlContainer: domElementTopics,
|
||||
options: optionsTopics,
|
||||
value: []
|
||||
|
||||
});
|
||||
const domElementTags = document.querySelector('#tags_ids');
|
||||
const treeselectTags = new Treeselect({
|
||||
parentHtmlContainer: domElementTags,
|
||||
options: optionsTags,
|
||||
value: []
|
||||
|
||||
});
|
||||
treeselectTags.srcElement.addEventListener('input', (e) => {
|
||||
tags_ids = e.detail?.join(',')
|
||||
});
|
||||
function initAddNewPost () {
|
||||
return {
|
||||
errors: 0,
|
||||
hasCaptchaToken: 0,
|
||||
showPassword: false,
|
||||
displayErrorMessage: false,
|
||||
errorMessages: [],
|
||||
setErrorMessages (messages) {
|
||||
this.errorMessages = [messages];
|
||||
this.displayErrorMessage = this.errorMessages.length
|
||||
},
|
||||
submitForm () {
|
||||
this.validate()
|
||||
.then(() => {
|
||||
const $form = document.querySelector('#mp_blog_post_form');
|
||||
if (this.errors === 0) {
|
||||
this.dispatchAddNewPostRequest($form);
|
||||
}
|
||||
})
|
||||
.catch((invalid) => {
|
||||
if (invalid.length > 0) {
|
||||
invalid[0].focus();
|
||||
}
|
||||
});
|
||||
},
|
||||
dispatchAddNewPostRequest: function (form) {
|
||||
const formData = new FormData();
|
||||
var imageInput = document.querySelector('#image');
|
||||
if (imageInput?.files.length > 0) {
|
||||
formData.append('image', imageInput.files[0]);
|
||||
} else {
|
||||
var emptyBlob = new Blob([''], {type: 'application/octet-stream'});
|
||||
formData.append('image', emptyBlob, 'empty_image.txt');
|
||||
}
|
||||
formData.append('name', document.querySelector('#name').value);
|
||||
formData.append('post_id', document.querySelector('#post_id').value);
|
||||
formData.append('short_description', document.querySelector('#short_description').value);
|
||||
formData.append('post_content', document.querySelector('#post_content').value);
|
||||
|
||||
formData.append('categories_ids', treeselectCategories.value?.join(','));
|
||||
formData.append('topics_ids', treeselectTopics.value?.join(','));
|
||||
formData.append('tags_ids', treeselectTags.value?.join(','));
|
||||
formData.append('allow_comment', document.querySelector('#allow_comment').value);
|
||||
|
||||
const publicDateValue = document.querySelector('#publish_date').value;
|
||||
if(publicDateValue) {
|
||||
formData.append('publish_date', convertDateToSave(publicDateValue));
|
||||
} else {
|
||||
formData.append('publish_date', '');
|
||||
}
|
||||
var checkboxElement = document.getElementById("post_image_delete");
|
||||
if(checkboxElement && checkboxElement.checked) {
|
||||
formData.append(checkboxElement.name, checkboxElement.value);
|
||||
}
|
||||
var imgElement= document.getElementById("post_image_image");
|
||||
if(imgElement) {
|
||||
|
||||
formData.append('image', imgElement.title);
|
||||
}
|
||||
|
||||
fetch("<?= $escaper->escapeHtml($block->getUrl('mpblog/post/manage')) ?>", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
body: formData,
|
||||
mode: "cors",
|
||||
credentials: "include"
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
<?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\Post\RelatedPost;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var Collection $posts */
|
||||
/** @var RelatedPost $block */
|
||||
/** @var Escaper $escaper */
|
||||
$posts = $block->getRelatedPostList();
|
||||
if ($posts && $block->isEnabledBlog()) : ?>
|
||||
<h2 class="text-xl"><?= $posts->getSize() ? $escaper->escapeHtml(__('Related Posts')) : $escaper->escapeHtml(__('No Related Posts')) ?></h2>
|
||||
<?php if ($block->getRelatedMode()) : ?>
|
||||
<div class="mp-blog-owl-carousel ">
|
||||
<section id="relatedposts-carousel" class="splide" aria-label="Related Posts">
|
||||
<div class="splide__track">
|
||||
<ul class="splide__list">
|
||||
<?php foreach ($posts as $post) : ?>
|
||||
<li class="splide__slide">
|
||||
<div class="item post-list-item col-mp post-item-list mp-4">
|
||||
<div class="post-item-wraper">
|
||||
<div class="post-info-wraper">
|
||||
<a href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<img class="img-responsive"
|
||||
src="<?= $escaper->escapeUrl($block->resizeImage($post->getImage(),
|
||||
'400x')) ?>"
|
||||
alt="<?= $escaper->escapeHtml($post->getName()); ?>"/>
|
||||
</a>
|
||||
<h2 class="mp-post-title" style="margin: 20px 0;">
|
||||
<a class="post-link-title"
|
||||
title="<?= $escaper->escapeHtml($post->getName()); ?>"
|
||||
href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<?= $escaper->escapeHtml($post->getName()) ?>
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
new Splide('#relatedposts-carousel', {
|
||||
perPage: 3,
|
||||
gap: 15,
|
||||
breakpoints: {
|
||||
1028: {
|
||||
perPage: 2
|
||||
}
|
||||
}
|
||||
}).mount();
|
||||
});
|
||||
</script>
|
||||
<?php else : ?>
|
||||
<ul class="relatedposts-list" style="list-style-type:disc; padding-left: 30px">
|
||||
<?php foreach ($posts as $post) : ?>
|
||||
<li>
|
||||
<a href="<?= $escaper->escapeUrl($post->getUrl()) ?>"><?= $escaper->escapeHtml($post->getName()) ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<style>
|
||||
.post-item-wraper:hover {
|
||||
border: 1px solid #eee;
|
||||
box-shadow: 3px 3px 4px 0 rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.splide__pagination {
|
||||
bottom: -0.5em;
|
||||
}
|
||||
|
||||
.splide__arrow {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.splide__pagination__page.is-active {
|
||||
background: #869791
|
||||
}
|
||||
.post-item-wraper {
|
||||
border: 1px solid #eee;
|
||||
padding: 10px !important;
|
||||
|
||||
}
|
||||
#relatedposts-carousel, .relatedposts-list a:visited, .alink:visited {
|
||||
color: #006bb4;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#relatedposts-carousel a:hover, .alink:hover {
|
||||
color: #006bb4;
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,959 @@
|
||||
<?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 Magento\Framework\Escaper;
|
||||
use Mageplaza\Blog\Block\Post\View;
|
||||
use Mageplaza\Blog\Helper\Image;
|
||||
use Mageplaza\Blog\Model\Config\Source\Comments\Type;
|
||||
|
||||
/** @var Escaper $escaper */
|
||||
/** @var View $block */
|
||||
$helper = $block->getBlogHelper();
|
||||
$_post = $block->getPost();
|
||||
$author = $helper->getAuthorByPost($_post);
|
||||
$authorName = $author !== null ? $author->getName() : '';
|
||||
$modifier = $helper->getAuthorByPost($_post, true);
|
||||
$modifierName = $modifier !== null ? $modifier->getName() : '';
|
||||
$isLogged = ($block->isLoggedIn()) ? 'Yes' : 'No';
|
||||
$color = $helper->getDisplayConfig('font_color');
|
||||
?>
|
||||
<div class="mp-blog-view">
|
||||
<!--div class="mp-blog-rss">
|
||||
<a href="<?= $escaper->escapeUrl($block->getRssUrl('post/rss')) ?>" class="bb-rss-icon">
|
||||
<img src="<?= $escaper->escapeUrl($block->getViewFileUrl('Mageplaza_Blog::media/images/rss.png')) ?>"
|
||||
width="16px">
|
||||
</a>
|
||||
</div-->
|
||||
<div class="mpcss post-view" id="mpblog-list-container">
|
||||
<div class="post-list-content col-md-12 col-sm-8">
|
||||
<div class="post-view-image col-xs-12">
|
||||
<?php if ($_post->getImage()) : ?>
|
||||
<img class="img-responsive" src="<?= $escaper->escapeUrl($block->getImageUrl($_post->getImage())) ?>"
|
||||
alt="<?= $escaper->escapeHtmlAttr($_post->getName()) ?>"/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="post-post_content col-xs-12">
|
||||
<?= /** @noEscape */
|
||||
$block->getPageFilter($_post->getPostContent() ?: '') ?>
|
||||
</div>
|
||||
<div class="mp-clear"></div>
|
||||
<?= $block->getChildHtml('mp_blog_post_info') ?>
|
||||
|
||||
<?= $block->getChildHtml('mp_blog_post_slider') ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($helper->isEnabledReview()) : ?>
|
||||
<div class="mp-blog-review-title">
|
||||
<span><?= $escaper->escapeHtml(__('Did you find it helpful?')) ?></span>
|
||||
</div>
|
||||
<div id="mp-blog-review">
|
||||
<div class="mp-blog-like" style="width: 155px">
|
||||
<i class="fa fa-thumbs-up" aria-hidden="true"></i>
|
||||
<span><?= $escaper->escapeHtml(__('LIKE')) ?></span>
|
||||
<span class="mp-blog-view">
|
||||
<?php if (!empty($block->getPostLike($_post->getId(), '1'))) : ?>
|
||||
(<?= $escaper->escapeHtml($block->getPostLike($_post->getId(), '1')) ?>)
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="mp-blog-dislike" style="width: 155px">
|
||||
<i class="fa fa-thumbs-down" aria-hidden="true"></i>
|
||||
<span><?= $escaper->escapeHtml(__('DISLIKE')) ?></span>
|
||||
<span class="mp-blog-view">
|
||||
<?php if (!empty($block->getPostLike($_post->getId(), '0'))) : ?>
|
||||
(<?= $escaper->escapeHtml($block->getPostLike($_post->getId(), '0')) ?>)
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mp-blog-review-label"></div>
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"#mp-blog-review": {
|
||||
"Mageplaza_Blog/js/helpful-rate": {
|
||||
"url": "<?= /* @noEscape */ $block->getUrl('mpblog/post/review') ?>",
|
||||
"post_id" : <?= /* @noEscape */ $_post->getId() ?>,
|
||||
"mode": <?= /* @noEscape */ $helper->getReviewMode() ?>
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var options = {
|
||||
url: "<?= /* @noEscape */ $block->getUrl('mpblog/post/review') ?>",
|
||||
post_id: "<?= /* @noEscape */ $_post->getId() ?>",
|
||||
mode: "<?= /* @noEscape */ $helper->getReviewMode() ?>"
|
||||
};
|
||||
|
||||
function create () {
|
||||
const formKey = hyva.getFormKey();
|
||||
|
||||
var post_id = options.post_id,
|
||||
url = options.url,
|
||||
subPostId = {};
|
||||
if (options.mode === '1') {
|
||||
fetch(url, {
|
||||
"headers": {
|
||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
"body": "form_key=" + formKey + '&post_id=' + post_id + '&action=3&mode=' + options.mode,
|
||||
"method": "POST",
|
||||
"mode": "cors",
|
||||
"credentials": "include"
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.status === 0) {
|
||||
disableReview(response.action);
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
} else {
|
||||
var storedPostData = JSON.parse(getCookie('mpblog_post_data'));
|
||||
if (storedPostData) {
|
||||
subPostId = storedPostData;
|
||||
if (subPostId[post_id] !== undefined) {
|
||||
disableReview(subPostId[post_id].type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelectorAll('#mp-blog-review div').forEach(function (el) {
|
||||
el.addEventListener('click', function () {
|
||||
var action = 0,
|
||||
currentPostIds = {},
|
||||
likeId = 0;
|
||||
|
||||
var storedPostIds = JSON.parse(getCookie('mpblog_post_data'));
|
||||
|
||||
if (this.classList.contains('mp-blog-like')) {
|
||||
action = 1;
|
||||
}
|
||||
|
||||
if (storedPostIds && storedPostIds[post_id] !== undefined && options.mode === '0') {
|
||||
likeId = storedPostIds[post_id].likeId;
|
||||
enableReview(storedPostIds[post_id].type);
|
||||
if (action === storedPostIds[post_id].type) {
|
||||
delete storedPostIds[post_id];
|
||||
document.cookie = 'mpblog_post_data=' + JSON.stringify(storedPostIds);
|
||||
} else {
|
||||
storedPostIds[post_id].type = action;
|
||||
disableReview(action);
|
||||
}
|
||||
}
|
||||
|
||||
fetch(url, {
|
||||
"headers": {
|
||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
"body": "form_key=" + formKey + '&post_id=' + post_id + '&action=' + action + '&mode=' + options.mode + '&likeId=' + likeId,
|
||||
"method": "POST",
|
||||
"mode": "cors",
|
||||
"credentials": "include"
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
var storedPostIds, jsonStringIds;
|
||||
if (response['postLike'] && options.mode === '0' && typeof currentPostIds[post_id] === 'undefined') {
|
||||
var storedPostIds = receiveCookiePostIds(post_id, action, response['postLike'], self);
|
||||
var jsonStringIds = JSON.stringify(storedPostIds);
|
||||
|
||||
document.cookie = 'mpblog_post_data=' + jsonStringIds + '; expires=Sun, 1 Jan 2023 00:00:00 GMT; path=/';
|
||||
}
|
||||
|
||||
if (response['status']) {
|
||||
if (response.sumLike) {
|
||||
document.querySelector('#mp-blog-review .mp-blog-like .mp-blog-view').textContent = '(' + response.sumLike + ')';
|
||||
} else {
|
||||
document.querySelector('#mp-blog-review .mp-blog-like .mp-blog-view').textContent = '';
|
||||
}
|
||||
if (response.sumDislike) {
|
||||
document.querySelector('#mp-blog-review .mp-blog-dislike .mp-blog-view').textContent = '(' + response.sumDislike + ')';
|
||||
} else {
|
||||
document.querySelector('#mp-blog-review .mp-blog-dislike .mp-blog-view').textContent = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (response['status']) {
|
||||
enableAllReview();
|
||||
if (response['postLike']) {
|
||||
disableReview(action);
|
||||
}
|
||||
}
|
||||
const reloadCustomerDataEvent = new CustomEvent("reload-customer-section-data");
|
||||
window.dispatchEvent(reloadCustomerDataEvent);
|
||||
window.scrollTo({
|
||||
top: document.body.offsetTop,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function disableReview (action) {
|
||||
if (action === '1') {
|
||||
document.querySelector('.mp-blog-like').style.backgroundColor = '#658259';
|
||||
} else {
|
||||
document.querySelector('.mp-blog-dislike').style.backgroundColor = '#9a6464';
|
||||
}
|
||||
}
|
||||
|
||||
function enableReview (action) {
|
||||
if (action === '1') {
|
||||
document.querySelector('.mp-blog-like').style.backgroundColor = '#6AA84F';
|
||||
} else {
|
||||
document.querySelector('.mp-blog-dislike').style.backgroundColor = '#EC3A3C';
|
||||
}
|
||||
}
|
||||
|
||||
function enableAllReview () {
|
||||
document.querySelector('.mp-blog-like').style.backgroundColor = '#6AA84F';
|
||||
document.querySelector('.mp-blog-dislike').style.backgroundColor = '#EC3A3C';
|
||||
}
|
||||
|
||||
function getCookie (name) {
|
||||
var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
|
||||
return v ? v[2] : null;
|
||||
}
|
||||
|
||||
function receiveCookiePostIds (postId, action, likeId) {
|
||||
var postData = {
|
||||
id: postId,
|
||||
type: action,
|
||||
likeId: likeId
|
||||
},
|
||||
receivedJsonStr = getCookie('mpblog_post_data'),
|
||||
postIds = JSON.parse(receivedJsonStr) || {};
|
||||
|
||||
if (postIds[postId] !== undefined) {
|
||||
return postIds;
|
||||
}
|
||||
postIds[postId] = postData;
|
||||
return postIds;
|
||||
}
|
||||
|
||||
create();
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
<?php if ($helper->getBlogConfig('platforms/fb_platform/fb_share') || $helper->getBlogConfig('platforms/x_platform/x_share')) : ?>
|
||||
<div class="mp-clear"></div>
|
||||
<div class="mpcss">
|
||||
<div id="sharing">
|
||||
<div class="share-col-left">
|
||||
<h5><?= $escaper->escapeHtml(__('Share this post')) ?></h5>
|
||||
</div>
|
||||
<div class="share-col-right">
|
||||
<div class="post-sharing-button flex">
|
||||
<?php if ($helper->getBlogConfig('platforms/x_platform/x_share')) : ?>
|
||||
<img class="img-responsive"
|
||||
src="<?= $escaper->escapeUrl($block->getViewFileUrl('Mageplaza_Blog::media/images/twitter.png')) ?>"
|
||||
alt="Share on Twitter"
|
||||
onclick="window.open('https://twitter.com/share?text=&url=<?= /* @noEscape */
|
||||
$_post->getUrl() ?>','Twitter-dialog','width=626,height=436'); return false;"
|
||||
style="cursor: pointer;width: 43%;position: relative; left: 0.5rem"
|
||||
/>
|
||||
<?php endif; ?>
|
||||
<?php if ($helper->getBlogConfig('platforms/fb_platform/fb_share')) : ?>
|
||||
<img class="img-responsive"
|
||||
src="<?= $escaper->escapeUrl($block->getViewFileUrl('Mageplaza_Blog::media/images/facebook.png')) ?>"
|
||||
alt="Share on Facebook"
|
||||
onclick="window.open('https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent('<?= /* @noEscape */
|
||||
$_post->getUrl() ?>'),'facebook-share-dialog','width=626,height=436'); return false;"
|
||||
style="cursor: pointer;"
|
||||
/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($authorName && $helper->showAuthorInfo()) :
|
||||
$block->resizeImage($author->getImage(), '135x', Image::TEMPLATE_MEDIA_TYPE_AUTH);
|
||||
?>
|
||||
<div class="block-blog-related about-admin">
|
||||
<h2><?= $escaper->escapeHtml(__('About the Author')) ?></h2>
|
||||
<div class="related-content-container">
|
||||
<div class="author-content-image">
|
||||
<img class="img-responsive"
|
||||
src="<?= /* @noEscape */
|
||||
$author->getImage()
|
||||
? $block->resizeImage($author->getImage(), '135x', Image::TEMPLATE_MEDIA_TYPE_AUTH)
|
||||
: $block->getDefaultAuthorImage() ?>">
|
||||
</div>
|
||||
<div class="author-content-information">
|
||||
<div class="author-name"><?= /* @noEscape */
|
||||
$authorName ?></div>
|
||||
<p class="author-description">
|
||||
<?= /* @noEscape */
|
||||
$author->getShortDescription() ? $block->getPageFilter($author->getShortDescription()) : '' ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="mp-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php $relatedPosts = $_post->getRelatedPostsCollection(); ?>
|
||||
<?php if ($relatedPosts && count($relatedPosts)) : ?>
|
||||
<div class="block-blog-related topic-list mpcss" style="width: 90%;">
|
||||
<h2><?= $escaper->escapeHtml(__('Related Posts')) ?></h2>
|
||||
<?php if ($block->getRelatedMode()) : ?>
|
||||
<div class="">
|
||||
<section id="card-carousel" class="splide" aria-label="Related Posts">
|
||||
<div class="splide__track">
|
||||
<ul class="splide__list">
|
||||
<?php foreach ($relatedPosts as $post) : ?>
|
||||
<li class="splide__slide">
|
||||
<div class="item post-list-item" style="margin-right: 10px">
|
||||
<div class="post-item-wraper">
|
||||
<div class="post-image">
|
||||
<?php if ($post->getImage()) : ?>
|
||||
<a href="<?= /* @noEscape */
|
||||
$post->getUrl() ?>">
|
||||
<img class="img-responsive"
|
||||
src="<?= $escaper->escapeUrl($block->resizeImage($post->getImage(),
|
||||
'400x')) ?>"
|
||||
alt="<?= $escaper->escapeHtmlAttr($post->getName()) ?>"/>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="post-info-wraper">
|
||||
<h2 class="mp-post-title">
|
||||
<a class="post-link-title"
|
||||
title="<?= $escaper->escapeHtmlAttr($post->getName()) ?>"
|
||||
href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<?= $escaper->escapeHtml($post->getName()) ?>
|
||||
</a>
|
||||
</h2>
|
||||
<div class="mp-post-info">
|
||||
<?= /* @noEscape */
|
||||
$block->getPostInfo($post); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<style>
|
||||
.splide__pagination {
|
||||
bottom: -0.5em;
|
||||
}
|
||||
|
||||
.splide__arrow {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.splide__pagination__page.is-active {
|
||||
background: #869791
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<?php else : ?>
|
||||
<div class="related-content-container" style="display: flex; flex-wrap: wrap;">
|
||||
<?php foreach ($relatedPosts as $post) : ?>
|
||||
<div class="post-list-item col-mp mp-6 mp-lg-4 mp-md-6 mp-xs-12">
|
||||
<div class="post-item-wraper">
|
||||
<div class="post-image">
|
||||
<?php if ($post->getImage()) : ?>
|
||||
<a href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<img class="img-responsive"
|
||||
src="<?= $escaper->escapeUrl($block->resizeImage($post->getImage(),
|
||||
'400x')) ?>"
|
||||
alt="<?= $escaper->escapeHtmlAttr($post->getName()) ?>"/>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="post-info-wraper">
|
||||
<h2 class="mp-post-title">
|
||||
<a class="post-link-title"
|
||||
title="<?= $escaper->escapeHtmlAttr($post->getName()); ?>"
|
||||
href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<?= $escaper->escapeHtml($post->getName()) ?>
|
||||
</a>
|
||||
</h2>
|
||||
<div class="mp-post-info">
|
||||
<?= /* @noEscape */
|
||||
$block->getPostInfo($post) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<div class="mp-clear"></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($helper->getBlogConfig('product_post/post_detail/enable_product')) : ?>
|
||||
<?php $relatedBlock = $block->getChildBlock('related_products'); ?>
|
||||
<?php if ($relatedBlock->hasProduct()) : ?>
|
||||
<div class="block-blog-related products-same-post page-products mpcss" style="width: 90%;">
|
||||
<h2><?= $helper->getBlogConfig('product_post/post_detail/title') ?: $escaper->escapeHtml(__('Related Products')) ?></h2>
|
||||
<div class="related-content-container">
|
||||
<?= $relatedBlock->toHtml(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php $typeComment = $block->helperComment('type'); ?>
|
||||
<?php if (((int) $typeComment !== Type::DISABLE) && $_post->getAllowComment()) : ?>
|
||||
<div class="block-blog-related blog-comment">
|
||||
<h2><?= $escaper->escapeHtml(__('Comments')) ?></h2>
|
||||
<?php if ((int) $typeComment === Type::DISQUS) : ?>
|
||||
<div class="related-content-container box-collateral box-reviews" id="post-reviews">
|
||||
<div id="disqus_thread"></div>
|
||||
<script type="text/javascript">
|
||||
var disShortName = '<?= /** @noEscape */ $block->helperComment('disqus'); ?>';
|
||||
|
||||
/* * * DON'T EDIT BELOW THIS LINE * * */
|
||||
(function () {
|
||||
var dsq = document.createElement('script');
|
||||
dsq.type = 'text/javascript';
|
||||
dsq.async = true;
|
||||
dsq.src = '//' + disShortName + '.disqus.com/embed.js';
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
<?php elseif ($typeComment == Type::FACEBOOK) : ?>
|
||||
<div class="related-content-container box-collateral box-reviews
|
||||
<?= /* @noEscape */
|
||||
$helper->getBlogConfig('comment/facebook_colorscheme') ?>"
|
||||
id="post-reviews">
|
||||
<div id="fb-root"></div>
|
||||
<script>(function (d, s, id) {
|
||||
var js, fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) return;
|
||||
js = d.createElement(s);
|
||||
js.id = id;
|
||||
js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v12.0&appId=<?=
|
||||
/* @noEscape */ $block->getDecrypt($block->helperComment('facebook_appid')) ?>";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, 'script', 'facebook-jssdk'));
|
||||
</script>
|
||||
<div class="fb-comments" data-href="<?= /* @noEscape */
|
||||
$_post->getUrl() ?>"
|
||||
data-numposts="<?= /* @noEscape */
|
||||
$block->helperComment('facebook_number_comment') ?>"
|
||||
data-width="100%"
|
||||
data-colorscheme="<?= /* @noEscape */
|
||||
$block->helperComment('facebook_colorscheme') ?>"
|
||||
data-order-by="<?= /* @noEscape */
|
||||
$block->helperComment('facebook_order_by') ?>">
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($typeComment == Type::DEFAULT_COMMENT) : ?>
|
||||
<div class="related-content-container container default-cmt">
|
||||
<?php if (!$block->isLoggedIn()) : ?>
|
||||
<div class="col-mp default-cmt__cmt-login">
|
||||
<button class="primary btn default-cmt__cmt-login__btn-login">
|
||||
<?= $escaper->escapeHtml(__('Login')) ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="col-mp mp-12" style="float: left;">
|
||||
<div class="default-cmt__content">
|
||||
<div class="default-cmt__content__cmt-block">
|
||||
<?php if (!$block->isLoggedIn()) : ?>
|
||||
<form id="default-cmt__content__cmt-block__guest-form"
|
||||
|
||||
x-data="Object.assign(hyva.formValidation($el), initCustomerCommentForm())"
|
||||
@submit.prevent="submitForm();"
|
||||
>
|
||||
<?= /* @noEscape */
|
||||
$block->getBlockHtml('formkey'); ?>
|
||||
<div class="col-mp mp-6 default-cmt__content__cmt-block__guest-box">
|
||||
<label for="default-cmt__content__cmt-block__guest-box__name-input">Name
|
||||
*</label>
|
||||
<input id="default-cmt__content__cmt-block__guest-box__name-input"
|
||||
type="text"
|
||||
name="default-cmt__content__cmt-block__guest-box__name-input"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('Your display name')) ?>"
|
||||
data-validate='{"required": true}'>
|
||||
</div>
|
||||
<div class="col-mp mp-6 default-cmt__content__cmt-block__guest-box">
|
||||
<label for="default-cmt__content__cmt-block__guest-box__email-input">Email
|
||||
*</label>
|
||||
<input id="default-cmt__content__cmt-block__guest-box__email-input"
|
||||
type="text"
|
||||
name="default-cmt__content__cmt-block__guest-box__email-input"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('Your email')) ?> "
|
||||
data-validate='{"required": true, "email": true}'
|
||||
>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<div class="default-cmt__content__cmt-block__cmt-box">
|
||||
<div class="col-mp mp-12">
|
||||
<label for="mp-guest-cmt-commentbox">Comment</label>
|
||||
<div>
|
||||
<textarea
|
||||
class="default-cmt__content__cmt-block__cmt-box__cmt-input w-full"
|
||||
maxlength="255"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('Type comments here...')) ?>">
|
||||
|
||||
</textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="default-cmt__content__cmt-block__cmt-box__cmt-btn">
|
||||
<div class="default-cmt_loading" style="display: none">
|
||||
<img
|
||||
src="<?= $escaper->escapeUrl($block->getViewFileUrl('images/loader-1.gif')) ?>"
|
||||
alt="Loading...">
|
||||
</div>
|
||||
<button class="default-cmt__content__cmt-block__cmt-box__cmt-btn__btn-submit
|
||||
primary btn btn-primary" type="submit" style="display: block"
|
||||
form="default-cmt__content__cmt-block__guest-form">
|
||||
<?= $escaper->escapeHtml(__('Comment')) ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="default-cmt__content__cmt-content">
|
||||
<?php
|
||||
$comments = $block->getPostComments($_post->getId());
|
||||
$block->getCommentsTree($comments, 0);
|
||||
?>
|
||||
<?= $block->getCommentsHtml() ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
//get login url, text of button like, reply
|
||||
var loginUrl = '<?= /* @noEscape */ $block->getLoginUrl(); ?>',
|
||||
like = '<?= /* @noEscape */ __('Like') ?>',
|
||||
reply = '<?= /* @noEscape */ __('Reply') ?>',
|
||||
isLogged = '<?= /* @noEscape */ $isLogged ?>',
|
||||
likedColor = '<?= /* @noEscape */ $color?>',
|
||||
messengerBox = {
|
||||
cmt_warning: '<?= /* @noEscape */ $block->getMessagesHtml('adderror',
|
||||
'Please write the comment.')?>',
|
||||
exist_email_warning: '<?= /* @noEscape */$block->getMessagesHtml('adderror',
|
||||
'This email is exist. Please <a href="' . $block->getLoginUrl() . '"> Login </a> as our customer.')?>',
|
||||
login_warning: '<?= /* @noEscape */ $block->getMessagesHtml('adderror',
|
||||
'You are not logged in. Please <a href="' . $block->getLoginUrl() . '"> Login </a> or <a href="' . $block->getRegisterUrl() . '"> Signup </a> to like or send a reply.</div>')?>',
|
||||
comment_approve: '<?= /* @noEscape */ $block->getMessagesHtml('addsuccess',
|
||||
'Your comment has been sent successfully. Please wait admin approve !')?>'
|
||||
};
|
||||
|
||||
require(['comment']);
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?= $block->getChildHtml('mp_blog_post_view_add') ?>
|
||||
</div>
|
||||
<style>
|
||||
.default-cmt__content__cmt-content.row {
|
||||
padding-inline-start: 40px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
if(document.getElementById('card-carousel')) {
|
||||
new Splide('#card-carousel', {
|
||||
perPage: 3,
|
||||
breakpoints: {
|
||||
1028: {
|
||||
perPage: 2
|
||||
}
|
||||
}
|
||||
}).mount();
|
||||
}
|
||||
|
||||
});
|
||||
var cmtBox = document.querySelector('.default-cmt__content__cmt-block__cmt-box__cmt-input');
|
||||
var submitCmt = document.querySelector('.default-cmt__content__cmt-block__cmt-box__cmt-btn__btn-submit');
|
||||
var defaultCmt = document.querySelector('ul.default-cmt__content__cmt-content:first-child');
|
||||
var likeBtn = defaultCmt.querySelectorAll('.btn-like');
|
||||
var replyBtn = defaultCmt.querySelectorAll('.btn-reply');
|
||||
|
||||
let loginBtnCmt = document.querySelector('.default-cmt__cmt-login__btn-login');
|
||||
if (loginBtnCmt) {
|
||||
loginBtnCmt.addEventListener('click', function () {
|
||||
var socialPopup = document.querySelector(".social-login-popup");
|
||||
if (socialPopup) {
|
||||
openMyDialog();
|
||||
showLogin();
|
||||
} else {
|
||||
window.location.href = loginUrl;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initCustomerCommentForm () {
|
||||
return {
|
||||
errors: 0,
|
||||
hasCaptchaToken: 0,
|
||||
showPassword: false,
|
||||
displayErrorMessage: false,
|
||||
errorMessages: [],
|
||||
setErrorMessages (messages) {
|
||||
this.errorMessages = [messages];
|
||||
this.displayErrorMessage = this.errorMessages.length
|
||||
},
|
||||
submitForm () {
|
||||
this.validate()
|
||||
.then(() => {
|
||||
const $form = document.querySelector('#default-cmt__content__cmt-block__guest-form');
|
||||
if (this.errors === 0) {
|
||||
this.dispatchCommentRequest($form);
|
||||
}
|
||||
})
|
||||
.catch((invalid) => {
|
||||
if (invalid.length > 0) {
|
||||
invalid[0].focus();
|
||||
}
|
||||
});
|
||||
},
|
||||
dispatchCommentRequest: function (form) {
|
||||
callApiSubmitComment();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function submitComment () {
|
||||
if (isLogged === 'Yes') {
|
||||
submitCmt.addEventListener('click', function () {
|
||||
callApiSubmitComment();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
submitComment();
|
||||
|
||||
async function callApiSubmitComment () {
|
||||
var messagesContainer = document.querySelector('.default-cmt__content__cmt-block__cmt-box .messages');
|
||||
if (messagesContainer) {
|
||||
messagesContainer.style.display = 'none';
|
||||
}
|
||||
|
||||
var cmtBox = document.querySelector('.default-cmt__content__cmt-block__cmt-box__cmt-input');
|
||||
var submitCmt = document.querySelector('.default-cmt__content__cmt-block__cmt-box__cmt-btn__btn-submit');
|
||||
var cmtText = cmtBox.value;
|
||||
if (cmtText.trim().length) {
|
||||
document.querySelector('.default-cmt_loading').style.display = 'block';
|
||||
this.disabled = true;
|
||||
await ajaxCommentActions(cmtText, submitCmt);
|
||||
cmtBox.value = '';
|
||||
document.querySelector('.default-cmt_loading').style.display = 'none';
|
||||
submitCmt.disabled = false;
|
||||
|
||||
} else {
|
||||
var cmtInputParent = document.querySelector('.default-cmt__content__cmt-block__cmt-box__cmt-input').parentElement;
|
||||
cmtInputParent.insertAdjacentHTML('beforeend', messengerBox.cmt_warning);
|
||||
}
|
||||
}
|
||||
|
||||
// ajax call api to comments
|
||||
function ajaxCommentActions (cmtText, inputEl, checkReply, cmtId, parentComment) {
|
||||
var isReply = (typeof checkReply !== 'undefined') ? 1 : 0,
|
||||
replyId = (typeof cmtId !== 'undefined') ? cmtId : 0,
|
||||
displayReply = (typeof checkReply !== 'undefined');
|
||||
var guestName = document.querySelector('#default-cmt__content__cmt-block__guest-box__name-input')?.value;
|
||||
|
||||
var guestEmail = document.querySelector('#default-cmt__content__cmt-block__guest-box__email-input')?.value;
|
||||
let url = window.location.href;
|
||||
const body = new URLSearchParams({
|
||||
form_key: hyva.getFormKey(),
|
||||
cmt_text: cmtText,
|
||||
isReply: isReply,
|
||||
replyId: replyId,
|
||||
guestName: guestName,
|
||||
guestEmail: guestEmail
|
||||
});
|
||||
fetch(url, {
|
||||
headers: {
|
||||
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
body: body,
|
||||
method: "POST",
|
||||
mode: "cors",
|
||||
credentials: "include"
|
||||
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
switch (data.status){
|
||||
case 'duplicated':
|
||||
document.querySelector('.default-cmt__content__cmt-block__cmt-box__cmt-input').parentElement.appendChild(document.createRange().createContextualFragment(messengerBox.exist_email_warning));
|
||||
break;
|
||||
case 3:
|
||||
document.querySelector('.default-cmt__content__cmt-block').insertAdjacentHTML('afterbegin', messengerBox.comment_approve);
|
||||
break;
|
||||
case 1:
|
||||
displayComment(data, displayReply);
|
||||
var cmtCount = document.querySelectorAll('.default-cmt li').length;
|
||||
if (document.querySelector('.mp-cmt-count')) {
|
||||
document.querySelector('.mp-cmt-count').textContent = cmtCount;
|
||||
}
|
||||
|
||||
inputEl.value = '';
|
||||
break;
|
||||
case 'error':
|
||||
if (checkReply !== 'undefined') {
|
||||
parentComment.insertAdjacentHTML('beforeend', data.error);
|
||||
} else {
|
||||
document.querySelector('.default-cmt').insertAdjacentHTML('beforeend', data.error);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
// handle display comments
|
||||
function displayComment (cmt, isReply) {
|
||||
function htmlComment (text) {
|
||||
var html = '';
|
||||
var sub = text.split("\n");
|
||||
for (var i = 0; i < sub.length; i++){
|
||||
html += '<p>' + sub[i] + '</p>';
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
var cmtRow = document.createElement('li');
|
||||
cmtRow.style.width = '100%';
|
||||
cmtRow.id = 'cmt-id-' + cmt.cmt_id;
|
||||
cmtRow.className = 'default-cmt__content__cmt-content__cmt-row cmt-row-' + cmt.cmt_id + ' cmt-row col-m-12' +
|
||||
(isReply ? ' reply-row' : '');
|
||||
cmtRow.setAttribute('data-cmt-id', cmt.cmt_id);
|
||||
if (isReply) {
|
||||
cmtRow.setAttribute('data-reply-id', cmt.reply_cmt);
|
||||
}
|
||||
|
||||
cmtRow.innerHTML = '<div class="cmt-row__cmt-username"> ' +
|
||||
'<span class="cmt-row__cmt-username username username__' + cmt.cmt_id + '">' + cmt.user_cmt + '</span> ' +
|
||||
'</div>' +
|
||||
'<div class="cmt-row__cmt-content"> ' +
|
||||
'<p>' + htmlComment(cmt.cmt_text) + '</p> ' +
|
||||
'</div>' +
|
||||
'<div class="cmt-row__cmt-interactions interactions"> <div class="interactions__btn-actions"> ' +
|
||||
'<a class="interactions__btn-actions action btn-like mpblog-like" data-cmt-id="' + cmt.cmt_id + '" click="1">' +
|
||||
'<i class="fa fa-thumbs-up" aria-hidden="true" style="margin-right: 3px"></i>' +
|
||||
'<span class="count-like__like-text"></span>' +
|
||||
'</a>' +
|
||||
'<a class="interactions__btn-actions action btn-reply" data-cmt-id="' + cmt.cmt_id + '">' + reply + '</a> ' +
|
||||
'</div>' +
|
||||
'<div class="interactions__cmt-createdat"> ' +
|
||||
'<span>' + cmt.created_at + '</span> ' +
|
||||
'</div> ';
|
||||
|
||||
if (isReply) {
|
||||
var replyCmtId = cmt.reply_cmt;
|
||||
var replyCmtList = document.querySelectorAll('.default-cmt__content__cmt-content__cmt-row');
|
||||
|
||||
replyCmtList.forEach(function (cmtEl) {
|
||||
if (cmtEl.getAttribute('data-cmt-id') === replyCmtId) {
|
||||
var replyList = cmtEl.querySelector('ul.default-cmt__content__cmt-content:first-child');
|
||||
|
||||
if (!replyList) {
|
||||
var newUl = document.createElement('ul');
|
||||
newUl.className = 'default-cmt__content__cmt-content row';
|
||||
newUl.appendChild(cmtRow);
|
||||
cmtEl.appendChild(newUl);
|
||||
|
||||
likeComment(cmtRow.querySelectorAll('.btn-like'));
|
||||
showReply(cmtRow.querySelectorAll('.btn-reply'));
|
||||
} else {
|
||||
replyList.appendChild(cmtRow);
|
||||
|
||||
likeComment(cmtRow.querySelectorAll('.btn-like'));
|
||||
showReply(cmtRow.querySelectorAll('.btn-reply'));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
defaultCmt.appendChild(cmtRow);
|
||||
|
||||
likeComment(cmtRow.querySelectorAll('.btn-like'));
|
||||
showReply(cmtRow.querySelectorAll('.btn-reply'));
|
||||
}
|
||||
}
|
||||
// handle click like comment
|
||||
function likeComment (btns) {
|
||||
btns.forEach(function (likeEl) {
|
||||
likeEl.addEventListener('click', function () {
|
||||
var cmtId = this.getAttribute('data-cmt-id');
|
||||
var cmtRowContainer = this.closest('.default-cmt__content__cmt-content__cmt-row');
|
||||
|
||||
if (isLogged === 'Yes') {
|
||||
var likeCountText = this.querySelector('span').textContent.trim();
|
||||
var likeCount = parseInt(likeCountText, 10) || 0; // Convert to integer, default to 0 if NaN
|
||||
if (this.getAttribute('click') === '1') {
|
||||
if (this.classList.contains('mpblog-liked')) {
|
||||
this.style.color = '#333333';
|
||||
likeCount--;
|
||||
this.querySelector('span').textContent = (likeCount === 0) ? "" : likeCount;
|
||||
this.classList.remove('mpblog-liked');
|
||||
} else {
|
||||
likeCount++;
|
||||
this.querySelector('span').textContent = likeCount;
|
||||
this.style.color = likedColor;
|
||||
this.classList.add('mpblog-liked');
|
||||
}
|
||||
|
||||
fetch(window.location.href, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
body: 'cmtId=' + cmtId,
|
||||
mode: "cors",
|
||||
credentials: "include"
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.status === 'ok') {
|
||||
likeEl.setAttribute('click', '1');
|
||||
} else if (response.status === 'error' && response.hasOwnProperty('error')) {
|
||||
var errorElement = document.createElement('div');
|
||||
errorElement.innerHTML = response.error;
|
||||
defaultCmt.appendChild(errorElement);
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
|
||||
likeEl.setAttribute('click', '0');
|
||||
} else {
|
||||
cmtRowContainer.insertAdjacentHTML('beforeend', messengerBox.login_warning);
|
||||
setTimeout(function () {
|
||||
var errorNotification = document.querySelector('.message.error.message-error');
|
||||
if (errorNotification) {
|
||||
errorNotification.parentElement.removeChild(errorNotification);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
likeComment(likeBtn);
|
||||
// handle show reply comment
|
||||
function showReply (btns) {
|
||||
btns.forEach(function (btn) {
|
||||
btn.addEventListener('click', function () {
|
||||
var cmtId = (typeof closestWithDataAttr(btn, 'data-cmt-id') !== 'undefined') ? closestWithDataAttr(btn, 'data-cmt-id') : btn.getAttribute('data-cmt-id');
|
||||
|
||||
var inputCmtID = this.getAttribute('data-cmt-id');
|
||||
var cmtRowCmt = document.querySelector('#cmt-row');
|
||||
var cmtRowContainer = this.closest('.default-cmt__content__cmt-content__cmt-row');
|
||||
|
||||
if (document.querySelectorAll('.cmt-row__reply-row.row__' + inputCmtID).length) {
|
||||
cmtRowContainer = document.querySelector("#cmt-id-" + cmtId + " ul:last-child");
|
||||
}
|
||||
|
||||
var cmtRow = cmtRowContainer.querySelector('.cmt-row__reply-row.row__' + inputCmtID);
|
||||
var cmtName = document.querySelector(".username__" + inputCmtID).textContent;
|
||||
|
||||
if (isLogged === 'Yes') {
|
||||
if (cmtRowCmt) {
|
||||
cmtRowCmt.style.display = (cmtRowCmt.style.display === 'none') ? 'block' : 'none';
|
||||
cmtRowCmt.parentElement.removeChild(cmtRowCmt);
|
||||
}
|
||||
|
||||
if (cmtRow) {
|
||||
cmtRow.style.display = (cmtRow.style.display === 'none') ? 'block' : 'none';
|
||||
cmtRow.parentElement.removeChild(cmtRow);
|
||||
} else {
|
||||
cmtRowContainer.insertAdjacentHTML('beforeend', '<div id="cmt-row" class="cmt-row__reply-row row row__' + inputCmtID + ' col-md-12">' +
|
||||
'<div class="reply-form__form-input form-group col-xs-8 col-md-6">' +
|
||||
'<label for="reply_cmt' + inputCmtID + '"></label>' +
|
||||
'<input type="text" id="reply_cmt' + inputCmtID + '" class="form-group__input form-control" placeholder="Press enter to submit reply" value="' + cmtName + ' " autofocus onfocus="this.setSelectionRange(1000,1001);"/>' +
|
||||
'</div>' +
|
||||
'</div>');
|
||||
|
||||
var input = document.getElementById('reply_cmt' + inputCmtID);
|
||||
input.closest('.form-group').appendChild(
|
||||
document.querySelector('.default-cmt__content__cmt-block__cmt-box__cmt-btn .default-cmt_loading').cloneNode(true)
|
||||
);
|
||||
input.focus();
|
||||
|
||||
submitReply(input, cmtId, cmtRowContainer);
|
||||
}
|
||||
} else {
|
||||
cmtRowContainer.insertAdjacentHTML('beforeend', messengerBox.login_warning);
|
||||
setTimeout(function () {
|
||||
var errorNotification = document.querySelector('.message.error.message-error');
|
||||
if (errorNotification) {
|
||||
errorNotification.parentElement.removeChild(errorNotification);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// handle find comment id closest
|
||||
function closestWithDataAttr (element, attribute) {
|
||||
while (element && !element.getAttribute(attribute)){
|
||||
element = element.parentNode;
|
||||
}
|
||||
return element ? element.getAttribute(attribute) : null;
|
||||
}
|
||||
|
||||
showReply(replyBtn);
|
||||
|
||||
var firstCmtRow = document.querySelector('li.default-cmt__content__cmt-content__cmt-row:first-child');
|
||||
if (firstCmtRow) {
|
||||
firstCmtRow.style.borderTop = 'none';
|
||||
}
|
||||
// handle reply comment
|
||||
function submitReply (input, replyId, parentComment) {
|
||||
input.addEventListener('keypress', async function (e) {
|
||||
var text = input.value;
|
||||
if (text !== '') {
|
||||
if (e.keyCode === 13) {
|
||||
input.nextElementSibling.style.display = 'block';
|
||||
input.disabled = true;
|
||||
await ajaxCommentActions(text, input, true, replyId, parentComment);
|
||||
input.closest('.cmt-row__reply-row').style.display = 'none';
|
||||
input.nextElementSibling.style.display = 'none';
|
||||
input.disabled = false;
|
||||
var cmtRow = document.getElementById('cmt-row');
|
||||
if (cmtRow) {
|
||||
cmtRow.remove();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,340 @@
|
||||
<?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 Magento\Catalog\Block\Product\ReviewRendererInterface;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Framework\App\Action\Action;
|
||||
use Mageplaza\Blog\Block\Post\RelatedProduct;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var $block RelatedProduct */
|
||||
/** @var Escaper $escaper */
|
||||
$_productCollection = $block->getLoadedProductCollection();
|
||||
$_helper = $block->getHelper();
|
||||
|
||||
?>
|
||||
<?php if (!$_productCollection->count()) : ?>
|
||||
<div class="message info empty">
|
||||
<div><?= $escaper->escapeHtml(__('We can\'t find products matching the selection.')) ?></div>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<?= $block->getToolbarHtml() ?>
|
||||
<?= $block->getAdditionalHtml() ?>
|
||||
<?php
|
||||
if ($block->getMode() == 'grid') {
|
||||
$viewMode = '';
|
||||
$imageDisplayArea = 'category_page_grid';
|
||||
$showDescription = false;
|
||||
$templateType = ReviewRendererInterface::SHORT_VIEW;
|
||||
} else {
|
||||
$viewMode = 'list';
|
||||
$imageDisplayArea = 'category_page_list';
|
||||
$showDescription = true;
|
||||
$templateType = ReviewRendererInterface::FULL_VIEW;
|
||||
}
|
||||
$pos = $block->getPositioned();
|
||||
?>
|
||||
<div class="products wrapper <?= /* @noEscape */ $viewMode ?> products-<?= /* @noEscape */ $viewMode ?>">
|
||||
<?php if ($block->relatedMode() !== '1') : ?>
|
||||
<div class="products list items product-items mt-6 grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4">
|
||||
<?php /** @var Product $_product */ ?>
|
||||
<?php foreach ($_productCollection as $_product) : ?>
|
||||
<div class="item product product-item">
|
||||
<div class="product-item-info" data-container="product-<?= /* @noEscape */
|
||||
$viewMode ?>">
|
||||
<?php
|
||||
$productImage = $block->getImage($_product, $imageDisplayArea);
|
||||
if ($pos != null) {
|
||||
$position = ' style="left:' . $productImage->getWidth() . 'px;'
|
||||
. 'top:' . $productImage->getHeight() . 'px;"';
|
||||
}
|
||||
?>
|
||||
<?php // Product Image ?>
|
||||
<a href="<?= $escaper->escapeUrl($block->getParentProductUrl($_product)) ?>"
|
||||
class="product photo product-item-photo"
|
||||
tabindex="-1">
|
||||
<?= $productImage->toHtml() ?>
|
||||
</a>
|
||||
<div class="product details product-item-details">
|
||||
<?php
|
||||
$_productNameStripped = $block->stripTags($_product->getName(), null, true);
|
||||
?>
|
||||
<strong class="product name product-item-name">
|
||||
<a class="product-item-link"
|
||||
href="<?= $escaper->escapeUrl($block->getParentProductUrl($_product)) ?>">
|
||||
<?= /* @noEscape */
|
||||
$_helper->productAttribute($_product, $_product->getName(), 'name') ?>
|
||||
</a>
|
||||
</strong>
|
||||
<?= $block->getReviewsSummaryHtml($_product, $templateType) ?>
|
||||
<?= /* @noEscape */
|
||||
$block->getProductPrice($_product) ?>
|
||||
<?= $block->getProductDetailsHtml($_product) ?>
|
||||
<div class="product-item-inner">
|
||||
<div class="product actions product-item-actions"
|
||||
<?= strpos((string) $pos, $viewMode . '-actions')
|
||||
? $escaper->escapeHtmlAttr($position) : '' ?>>
|
||||
<div class="actions-primary"
|
||||
<?= strpos((string) $pos, $viewMode . '-primary')
|
||||
? $escaper->escapeHtmlAttr($position) : '' ?>>
|
||||
<?php if ($_product->isSaleable()) : ?>
|
||||
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
|
||||
<form data-role="tocart-form"
|
||||
data-product-sku="<?= $escaper->escapeHtml($_product->getSku()) ?>"
|
||||
action="<?= $escaper->escapeUrl($postParams['action']) ?>"
|
||||
method="post">
|
||||
<input type="hidden" name="product"
|
||||
value="<?= /* @noEscape */
|
||||
$postParams['data']['product'] ?>">
|
||||
<input type="hidden" name="<?= /* @noEscape */
|
||||
Action::PARAM_NAME_URL_ENCODED ?>"
|
||||
value="<?= /* @noEscape */
|
||||
$postParams['data'][Action::PARAM_NAME_URL_ENCODED] ?>">
|
||||
<?= $block->getBlockHtml('formkey') ?>
|
||||
<button type="submit"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Add to Cart')) ?>"
|
||||
class="action tocart btn btn-primary">
|
||||
<span><?= $escaper->escapeHtml(__('Add to Cart')) ?></span>
|
||||
</button>
|
||||
</form>
|
||||
<?php else : ?>
|
||||
<?php if ($_product->isAvailable()) : ?>
|
||||
<div class="stock available">
|
||||
<span><?= $escaper->escapeHtml(__('In stock')) ?></span></div>
|
||||
<?php else : ?>
|
||||
<div class="stock unavailable">
|
||||
<span><?= $escaper->escapeHtml(__('Out of stock')) ?></span></div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div data-role="add-to-links" class="actions-secondary"
|
||||
<?= strpos((string) $pos, $viewMode . '-secondary')
|
||||
? $escaper->escapeHtmlAttr($position) : '' ?>>
|
||||
<?php if ($addToBlock = $block->getChildBlock('addto')) : ?>
|
||||
<?= $addToBlock->setProduct($_product)->getChildHtml() ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($showDescription) : ?>
|
||||
<div class="product description product-item-description">
|
||||
<?= /* @noEscape */
|
||||
$_helper->productAttribute(
|
||||
$_product,
|
||||
$_product->getShortDescription(),
|
||||
'short_description'
|
||||
) ?>
|
||||
<a href="<?= $escaper->escapeUrl($block->getParentProductUrl($_product)) ?>"
|
||||
title="<?= /* @noEscape */
|
||||
$_productNameStripped ?>"
|
||||
class="action more"><?= $escaper->escapeHtml(__('Learn More')) ?></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<style>
|
||||
.page-products .product-item-info {
|
||||
width: 220px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<?php else : ?>
|
||||
<div class="">
|
||||
<?php /** @var $_product Product */ ?>
|
||||
<section id="products-carousel" class="splide" aria-label="Related Products">
|
||||
<div class="splide__track">
|
||||
<ul class="splide__list">
|
||||
<?php foreach ($_productCollection as $_product) : ?>
|
||||
<li class="splide__slide">
|
||||
<div class="item product product-item mp-blog-slider-item">
|
||||
<div class="product-item-info" data-container="product-<?= /* @noEscape */
|
||||
$viewMode ?>">
|
||||
<?php
|
||||
$productImage = $block->getImage($_product, $imageDisplayArea);
|
||||
if ($pos != null) {
|
||||
$position = ' style="left:' . $productImage->getWidth() . 'px;'
|
||||
. 'top:' . $productImage->getHeight() . 'px;"';
|
||||
}
|
||||
?>
|
||||
<?php // Product Image ?>
|
||||
<a href="<?= $escaper->escapeUrl($block->getParentProductUrl($_product)) ?>"
|
||||
class="product photo product-item-photo"
|
||||
tabindex="-1">
|
||||
<?= $productImage->toHtml() ?>
|
||||
</a>
|
||||
<div class="product details product-item-details">
|
||||
<?php
|
||||
$_productNameStripped = $block->stripTags($_product->getName(), null,
|
||||
true);
|
||||
?>
|
||||
<strong class="product name product-item-name">
|
||||
<a class="product-item-link"
|
||||
href="<?= $escaper->escapeUrl($block->getParentProductUrl($_product)) ?>">
|
||||
<?= /* @noEscape */
|
||||
$_helper->productAttribute($_product, $_product->getName(),
|
||||
'name') ?>
|
||||
</a>
|
||||
</strong>
|
||||
<?= $block->getReviewsSummaryHtml($_product, $templateType) ?>
|
||||
<?= /* @noEscape */
|
||||
$block->getProductPrice($_product) ?>
|
||||
<?= $block->getProductDetailsHtml($_product) ?>
|
||||
<div class="product-item-inner">
|
||||
<div class="product actions product-item-actions"
|
||||
<?= strpos((string) $pos, $viewMode . '-actions')
|
||||
? $escaper->escapeHtmlAttr($position) : '' ?>>
|
||||
<div class="actions-primary"
|
||||
<?= strpos((string) $pos, $viewMode . '-primary')
|
||||
? $escaper->escapeHtmlAttr($position) : '' ?>>
|
||||
<?php if ($_product->isSaleable()) : ?>
|
||||
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
|
||||
<form data-role="tocart-form"
|
||||
data-product-sku="<?= $escaper->escapeHtml($_product->getSku()) ?>"
|
||||
action="<?= $escaper->escapeUrl($postParams['action']) ?>"
|
||||
method="post">
|
||||
<input type="hidden"
|
||||
name="product"
|
||||
value="<?= /* @noEscape */
|
||||
$postParams['data']['product'] ?>">
|
||||
<input type="hidden" name="<?= /* @noEscape */
|
||||
Action::PARAM_NAME_URL_ENCODED ?>"
|
||||
value="<?= /* @noEscape */
|
||||
$postParams['data'][Action::PARAM_NAME_URL_ENCODED] ?>">
|
||||
<?= $block->getBlockHtml('formkey') ?>
|
||||
<button type="submit"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Add to Cart')) ?>"
|
||||
class="action tocart btn btn-primary">
|
||||
<span><?= $escaper->escapeHtml(__('Add to Cart')) ?></span>
|
||||
</button>
|
||||
</form>
|
||||
<?php else : ?>
|
||||
<?php if ($_product->isAvailable()) : ?>
|
||||
<div class="stock available">
|
||||
<span><?= $escaper->escapeHtml(__('In stock')) ?></span>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="stock unavailable">
|
||||
<span><?= $escaper->escapeHtml(__('Out of stock')) ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div data-role="add-to-links" class="actions-secondary"
|
||||
<?= strpos((string) $pos, $viewMode . '-secondary')
|
||||
? $escaper->escapeHtmlAttr($position) : '' ?>>
|
||||
<?php if ($addToBlock = $block->getChildBlock('addto')) : ?>
|
||||
<?= $addToBlock->setProduct($_product)->getChildHtml() ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($showDescription) : ?>
|
||||
<div class="product description product-item-description">
|
||||
<?= /* @noEscape */
|
||||
$_helper->productAttribute(
|
||||
$_product,
|
||||
$_product->getShortDescription(),
|
||||
'short_description'
|
||||
) ?>
|
||||
<a href="<?= $escaper->escapeUrl($block->getParentProductUrl($_product)) ?>"
|
||||
title="<?= /* @noEscape */
|
||||
$_productNameStripped ?>"
|
||||
class="action more"><?= $escaper->escapeHtml(__('Learn More')) ?></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
new Splide('#products-carousel', {
|
||||
perPage: 3,
|
||||
breakpoints: {
|
||||
1028: {
|
||||
perPage: 2
|
||||
}
|
||||
}
|
||||
}).mount();
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?= $block->getToolbarHtml() ?>
|
||||
<?php if (!$block->isRedirectToCartEnabled()) : ?>
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"[data-role=tocart-form], .form.map.checkout": {
|
||||
"catalogAddToCart": {
|
||||
"product_sku": "<?= $escaper->escapeJs($_product->getSku()) ?>"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<style>
|
||||
|
||||
.product-item .price-box {
|
||||
margin: 10px 0 25px;
|
||||
}
|
||||
|
||||
|
||||
.item.product.product-item.mp-blog-slider-item {
|
||||
width: 85%;
|
||||
text-align: center;
|
||||
min-height: 450px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.product-item-info:hover, .products-grid .product-item-info.active {
|
||||
|
||||
background: #ffffff;
|
||||
box-shadow: 3px 4px 4px 0 rgba(0, 0, 0, 0.3);
|
||||
border: 1px solid #bbbbbb;
|
||||
margin: -10px;
|
||||
padding: 18px;
|
||||
position: relative;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
.product-item-info:hover .btn.btn-primary {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.btn.btn-primary {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.products-grid .product-item-actions {
|
||||
margin: -10px 0 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
<?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"}}' x-data="{ activeTab: 0 }">
|
||||
<div class="data item title" data-role="collapsible" id="tab-label-popular" @click="activeTab = 0" :class="{ 'active': activeTab === 0 }">
|
||||
<a class="data switch" tabindex="-1" data-toggle="switch" id="tab-label-popular-title" >
|
||||
<div class="text-center"><?= $escaper->escapeHtml(__('Popular')) ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="data item content" id="tab-content-popular" data-role="content" :class="{ 'active': activeTab === 0 }" x-show.transition.in.opacity.duration.600="activeTab === 0">
|
||||
<?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" @click="activeTab = 1" :class="{ 'active': activeTab === 1 }">
|
||||
<a class="data switch" tabindex="-1" data-toggle="switch" id="tab-label-mostview-title" >
|
||||
<div class="text-center"><?= $escaper->escapeHtml(__('Latest')) ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="data item content" id="tab-content-mostview" data-role="content" :class="{ 'active': activeTab === 1 }" x-show.transition.in.opacity.duration.600="activeTab === 1">
|
||||
<?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>
|
||||
@@ -0,0 +1,154 @@
|
||||
<?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 id="autocomplete-results" class="autocomplete-suggestions" style="display: none;position: absolute;z-index: 100;width: 100%" >
|
||||
<!-- Autocomplete results here -->
|
||||
</div>
|
||||
</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>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var visibleImage = <?php echo /** @noEscape */ json_encode($block->getSidebarConfig('search/show_image')); ?>;
|
||||
var searchBox = document.getElementById('mpblog-search-box');
|
||||
let minChars = <?= $block->getSidebarConfig('search/min_chars') ?: 1; ?>;
|
||||
searchBox.addEventListener('input', function () {
|
||||
var searchTerm = searchBox.value;
|
||||
fetchSuggestions(searchTerm);
|
||||
});
|
||||
|
||||
function fetchSuggestions (searchTerm) {
|
||||
updateAutocompleteResults(<?php echo /** @noEscape */ ($block->getSearchBlogData()); ?>, searchTerm);
|
||||
}
|
||||
|
||||
function updateAutocompleteResults (suggestions, searchTerm) {
|
||||
var autocompleteResults = document.getElementById('autocomplete-results');
|
||||
autocompleteResults.innerHTML = '';
|
||||
if (searchTerm && searchTerm.length >= minChars) {
|
||||
if (suggestions.length > 0) {
|
||||
autocompleteResults.style.display = 'block';
|
||||
var existedPost = false;
|
||||
var limitPost = <?= $block->getSidebarConfig('search/search_limit') ?: 10; ?>;
|
||||
let checkNumberPostRender = 0;
|
||||
suggestions.forEach(function (suggestion, index) {
|
||||
|
||||
if (suggestion.value.toLocaleLowerCase().includes(searchTerm.toLowerCase())) {
|
||||
checkNumberPostRender ++;
|
||||
if (checkNumberPostRender > limitPost) {
|
||||
return;
|
||||
}
|
||||
existedPost = true;
|
||||
var suggestionDiv = document.createElement('div');
|
||||
suggestionDiv.className = 'mpblog-suggestion';
|
||||
|
||||
var suggestionDivParrent = document.createElement('div');
|
||||
suggestionDivParrent.className = 'autocomplete-suggestion list-post-tabs cursor-pointer';
|
||||
|
||||
if (visibleImage && visibleImage !== '0') {
|
||||
var suggestionLeftDiv = document.createElement('div');
|
||||
suggestionLeftDiv.className = 'mpblog-suggestion-left';
|
||||
var img = document.createElement('img');
|
||||
img.className = 'img-responsive';
|
||||
img.src = suggestion.image;
|
||||
suggestionLeftDiv.appendChild(img);
|
||||
suggestionDiv.appendChild(suggestionLeftDiv);
|
||||
}
|
||||
|
||||
var suggestionRightDiv = document.createElement('div');
|
||||
suggestionRightDiv.className = 'mpblog-suggestion-right ' + (visibleImage ? 'image-visible' : '');
|
||||
|
||||
var productLineDiv = document.createElement('div');
|
||||
productLineDiv.className = 'mpblog-product-line mpblog-product-name';
|
||||
productLineDiv.textContent = suggestion.value;
|
||||
suggestionRightDiv.appendChild(productLineDiv);
|
||||
|
||||
var productDesDiv = document.createElement('div');
|
||||
productDesDiv.className = 'mpblog-product-des';
|
||||
var shortDesP = document.createElement('p');
|
||||
shortDesP.className = 'mpblog-short-des';
|
||||
shortDesP.textContent = suggestion.desc;
|
||||
productDesDiv.appendChild(shortDesP);
|
||||
|
||||
suggestionRightDiv.appendChild(productDesDiv);
|
||||
suggestionDiv.appendChild(suggestionRightDiv);
|
||||
suggestionDivParrent.appendChild(suggestionDiv);
|
||||
suggestionDivParrent.addEventListener("click", function () {
|
||||
window.location.href = suggestion.url;
|
||||
});
|
||||
autocompleteResults.appendChild(suggestionDivParrent);
|
||||
}
|
||||
});
|
||||
if (!existedPost) {
|
||||
var suggestionDivParrent = document.createElement('div');
|
||||
suggestionDivParrent.className = 'autocomplete-suggestion';
|
||||
suggestionDivParrent.innerText = "No results";
|
||||
autocompleteResults.appendChild(suggestionDivParrent);
|
||||
|
||||
}
|
||||
} else {
|
||||
autocompleteResults.style.display = 'none';
|
||||
}
|
||||
} else {
|
||||
autocompleteResults.style.display = 'none';
|
||||
}
|
||||
}
|
||||
searchBox.addEventListener("blur",function (e) {
|
||||
setTimeout(() => {
|
||||
var autocompleteResults = document.getElementById('autocomplete-results');
|
||||
autocompleteResults.style.display = 'none';
|
||||
},150);
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
<?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\Widget\Posts;
|
||||
use Magento\Framework\Escaper;
|
||||
|
||||
/** @var Posts $block */
|
||||
/** @var Escaper $escaper */
|
||||
$posts = $block->getCollection();
|
||||
?>
|
||||
|
||||
<div class="blog-widget-title"><a></a></div>
|
||||
<div class="post-list-container mpcss" id="mpblog-list-container" style="margin-bottom: 50px">
|
||||
<div class="widget-title">
|
||||
<a href="<?= $escaper->escapeUrl($block->getBlogUrl('')) ?>"><?= $escaper->escapeHtml($block->getTitle()) ?></a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php foreach ($posts as $post) : ?>
|
||||
<div class="post-list-item" style="margin-left: 5px">
|
||||
<div class="post-item-wraper">
|
||||
<?php if ($post->getImage()) : ?>
|
||||
<div class="post-image">
|
||||
<a href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<img class="img-responsive" style="height: 220px; margin:auto"
|
||||
src="<?= $escaper->escapeUrl($block->resizeImage($post->getImage(), '400x')) ?>"
|
||||
alt="<?= $escaper->escapeHtml($post->getName()); ?>"/>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="post-info-wraper">
|
||||
<h2 class="mp-post-title" style="font-size: 22px">
|
||||
<a class="post-link-title" title="<?= $escaper->escapeHtmlAttr($post->getName()) ?>"
|
||||
href="<?= $escaper->escapeUrl($post->getUrl()) ?>">
|
||||
<?= $escaper->escapeHtml($post->getName()) ?>
|
||||
</a>
|
||||
</h2>
|
||||
<div class="mp-post-info">
|
||||
<?= /** @noEscape */ $block->getPostInfo($post) ?>
|
||||
</div>
|
||||
<div class="post-short-description">
|
||||
<p><?= /** @noEscape */ $post->getShortDescription() ?></p>
|
||||
</div>
|
||||
<div class="mp-clearfix"></div>
|
||||
<div class="mp-post-meta-info mp-alignright">
|
||||
<div class="actions">
|
||||
<a class="mp-read-more" href="<?= $escaper->escapeUrl($post->getUrl()) ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Read More')) ?>">
|
||||
<?= $escaper->escapeHtml(__('Read more')) ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.mp-post-info {
|
||||
color: #999999;
|
||||
font-size: 10px;
|
||||
line-height: 30px;
|
||||
margin: 0;
|
||||
}
|
||||
.post-item-wraper:hover {
|
||||
border: 1px solid #eee;
|
||||
box-shadow: 3px 3px 4px 0 rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.post-item-wraper {
|
||||
padding: 10px !important;
|
||||
border: 1px solid #eee;
|
||||
|
||||
}
|
||||
.post-list-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user