Skip to content

Commit

Permalink
Merge pull request #372 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
chuccv authored Oct 21, 2024
2 parents 4f75da5 + 882c315 commit 0ac258a
Show file tree
Hide file tree
Showing 13 changed files with 230 additions and 31 deletions.
13 changes: 13 additions & 0 deletions Block/Widget/Posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,17 @@ public function getBlogUrl($code)
{
return $this->helperData->getBlogUrl($code);
}

/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
{
if ($this->helperData->checkHyvaTheme()) {
$this->setTemplate('Mageplaza_Blog::hyva/widget/posts.phtml');
}
return parent::_toHtml();
}
}
4 changes: 2 additions & 2 deletions Plugin/HyvaMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function afterGetNavigation(
"is_category" => true,
"is_parent_active" => true,
"position" => null,
"path" => "1/2/38" . $key,
"path" => $category->getPath(),
"childData" => $blockMenu->getChildDataCate($category)
];
array_push($childData, $data);
Expand All @@ -95,7 +95,7 @@ public function afterGetNavigation(
"is_category" => true,
"is_parent_active" => true,
"position" => null,
"path" => "1/2/39",
"path" => $blockMenu->getPath(),
"childData" => $childData
];
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"mageplaza/facebook-graph-sdk": "^1.0.1"
},
"type": "magento2-module",
"version": "4.2.4",
"version": "4.2.5",
"license": "proprietary",
"keywords": [
"magento 2",
Expand Down
8 changes: 6 additions & 2 deletions view/frontend/layout/hyva_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@
</action>
</referenceBlock>

<referenceBlock name="footer-content">
<block class="Mageplaza\Blog\Block\Html\Footer" name="mp_blog_footer_link" template="Mageplaza_Blog::hyva/html/footer.phtml" after="-"/>

<referenceBlock name="footer-static-links">
<action method="setTemplate">
<argument name="template" xsi:type="string">Mageplaza_Blog::hyva/html/footer/links.phtml</argument>
</action>
<block class="Mageplaza\Blog\Block\Html\Footer" name="mp_blog_footer_link" template="Mageplaza_Blog::hyva/html/footer.phtml" after="-" ifconfig="blog/general/enabled"/>
</referenceBlock>

<referenceBlock name="related.category.products">
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/templates/hyva/design.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use Magento\Framework\Escaper;
columns.removeChild(sidebarMain);
}
}
var currentTheme = "<?php echo $block->getCurrentTheme(); ?>";
var currentTheme = "<?php echo /** @noEscape */ $block->getCurrentTheme() ?>";
if (currentTheme === "Etheme/yourstore") {
body.classList.add('mpblog-etheme-yourstore');
}
Expand Down
18 changes: 7 additions & 11 deletions view/frontend/templates/hyva/html/footer.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ $helper = $block->getHelperData();
?>
<?php if ($helper->isEnabled()) : ?>
<?php if ($helper->getBlogConfig('display/footer')) : ?>
<div class="pr-4 lg:w-1/4 md:w-1/2">
<ul>
<li>
<a class="text-base leading-6" <?= /** @noEscape */ $block->getLinkAttributes() ?>>
<?= $escaper->escapeHtml($block->getLabel()); ?>
<?= ($block->getCounter()) ? '<span>' . $escaper->escapeHtml($block->getCounter()) . '</span>' : ''; ?>
</a>
</li>
</ul>
</div>
<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; ?>
<?= $block->getChildHtml('mp_blog_footer_add') ?>
<?php endif; ?>
87 changes: 87 additions & 0 deletions view/frontend/templates/hyva/html/footer/links.phtml
Original file line number Diff line number Diff line change
@@ -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>
10 changes: 5 additions & 5 deletions view/frontend/templates/hyva/post/author_post.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ $jsonData = json_encode($postDatas);
class="action primary btn btn-primary" title="<?= $escaper->escapeHtmlAttr(__('Add New Post')) ?>">
<?= $escaper->escapeHtml(__('Add New Post')) ?>
</button>
<?= $modalViewModel->createModal()
<?= /** @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")
Expand Down Expand Up @@ -119,7 +119,7 @@ HTML
</div>
<div class="post-info-action" data-postId="<?= $escaper->escapeHtml($post->getId()); ?>">
<div class="mpblog-post-duplicate"
onclick='handleDuplicate(this,<?= json_encode($post->getData()) ?>)'
onclick='handleDuplicate(this,<?= /** @noEscape */ json_encode($post->getData()) ?>)'
>
<img
src="<?= $escaper->escapeUrl($block->getViewFileUrl('Mageplaza_Blog::media/images/duplicate.svg')) ?>"
Expand All @@ -129,7 +129,7 @@ HTML
/>
</div>
<div class="mpblog-post-edit"
onclick='handleEdit(this,<?= json_encode($post->getData()) ?>)'>
onclick='handleEdit(this,<?= /** @noEscape */ json_encode($post->getData()) ?>)'>
<img src="<?= $escaper->escapeUrl($block->getViewFileUrl('Mageplaza_Blog::media/images/writing.svg')) ?>"
align="middle"
alt="<?= $escaper->escapeHtmlAttr(__('Edit')); ?>"
Expand Down Expand Up @@ -205,7 +205,7 @@ HTML
// open modal edit new post
function handleEdit (e, data) {
resetFormModal();
let listData = <?php echo json_decode($jsonData) ?>;
let listData = <?php echo /** @noEscape */ json_decode($jsonData) ?>;
let dataSelect = listData[data?.post_id];
name.value = dataSelect?.name;
post_id.value = dataSelect?.post_id;
Expand All @@ -225,7 +225,7 @@ HTML
// open modal duplicate new post
function handleDuplicate (e, data) {
resetFormModal();
let listData = <?php echo json_decode($jsonData) ?>;
let listData = <?php echo /** @noEscape */ json_decode($jsonData) ?>;
let dataSelect = listData[data?.post_id];
name.value = dataSelect?.name;
short_description.value = dataSelect?.short_description;
Expand Down
6 changes: 3 additions & 3 deletions view/frontend/templates/hyva/post/manage_post.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ use Magento\Framework\Escaper;
console.error(err.stack);
});

const categories = <?php echo($block->getCategoriesTree()) ?>;
const topics = <?php echo($block->getTopicTree()) ?>;
const tags = <?php echo($block->getTagTree()) ?>;
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,
Expand Down
1 change: 1 addition & 0 deletions view/frontend/templates/hyva/post/relatedpost.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ if ($posts && $block->isEnabledBlog()) : ?>
document.addEventListener('DOMContentLoaded', function () {
new Splide('#relatedposts-carousel', {
perPage: 3,
gap: 15,
breakpoints: {
1028: {
perPage: 2
Expand Down
13 changes: 8 additions & 5 deletions view/frontend/templates/hyva/sidebar/search.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,32 @@ use Magento\Framework\Escaper;
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
var visibleImage = <?php echo json_encode($block->getSidebarConfig('search/show_image')); ?>;
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($block->getSearchBlogData()); ?>, searchTerm);
updateAutocompleteResults(<?php echo /** @noEscape */ ($block->getSearchBlogData()); ?>, searchTerm);
}

function updateAutocompleteResults (suggestions, searchTerm) {
var autocompleteResults = document.getElementById('autocomplete-results');
autocompleteResults.innerHTML = '';
if (searchTerm) {
if (searchTerm && searchTerm.length >= minChars) {
if (suggestions.length > 0) {
autocompleteResults.style.display = 'block';
var existedPost = false;
var limitPost = 10;
var limitPost = <?= $block->getSidebarConfig('search/search_limit') ?: 10; ?>;
let checkNumberPostRender = 0;
suggestions.forEach(function (suggestion, index) {

if (suggestion.value.toLocaleLowerCase().includes(searchTerm.toLowerCase())) {
if (index + 1 > limitPost) {
checkNumberPostRender ++;
if (checkNumberPostRender > limitPost) {
return;
}
existedPost = true;
Expand Down
95 changes: 95 additions & 0 deletions view/frontend/templates/hyva/widget/posts.phtml
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 1 addition & 1 deletion view/frontend/templates/post/info/category.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ $_post = $block->getPost();
<?php if ($categoryHtml = $block->getPostCategoryHtml($_post)) : ?>
|
<span><i class="fa fa-folder-open-o">&nbsp;</i>
<?= $escaper->escapeHtml(__('Categories: %1', $categoryHtml)); ?>
<?= /* @noEscape */ (__('Categories: %1', $categoryHtml)); ?>
</span>
<?php endif; ?>

0 comments on commit 0ac258a

Please sign in to comment.