Skip to content

Commit

Permalink
Merge pull request #14 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
Victor-Mageplaza committed Jun 6, 2021
2 parents 2ea82d3 + bf12bc0 commit 2cfdaef
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Block/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,12 @@ public function isEnabled()
{
return $this->helperData->isEnabled();
}

/**
* @return string
*/
public function getPosition()
{
return $this->helperData->getConfigGeneral('position');
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mageplaza/module-core": "^1.4.5"
},
"type": "magento2-module",
"version": "4.0.0",
"version": "4.0.1",
"license": "proprietary",
"authors": [
{
Expand Down
38 changes: 38 additions & 0 deletions view/frontend/layout/default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<!--
/**
* 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_GoogleMaps
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="main">
<block class="Magento\Framework\View\Element\Template" name="mp.googlemaps.map.top" before="-" template="Mageplaza_GoogleMaps::map/widget_position.phtml" ifconfig="mpgooglemaps/general/enabled">
<arguments>
<argument name="position" xsi:type="string">top</argument>
</arguments>
</block>
<block class="Magento\Framework\View\Element\Template" name="mp.googlemaps.map.bottom" after="-" template="Mageplaza_GoogleMaps::map/widget_position.phtml" ifconfig="mpgooglemaps/general/enabled">
<arguments>
<argument name="position" xsi:type="string">bottom</argument>
</arguments>
</block>
</referenceContainer>
</body>
</page>
17 changes: 17 additions & 0 deletions view/frontend/templates/map.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

/** @var \Mageplaza\GoogleMaps\Block\Map $block */
$position = $block->getPosition();
?>
<?php if ($block->isEnabled()): ?>
<?php if ((int)$block->getProtocol() === Mageplaza\GoogleMaps\Model\Config\Source\System\Protocol::API): ?>
Expand Down Expand Up @@ -63,9 +64,25 @@
markerMap(latitude, longitude);
});
</script>
<script type="text/javascript">
var position = '<?= $position ?>';
if (position === 'top') {
document.getElementsByClassName('mpgooglemaps_map')[1].style.display = 'none';
} else {
document.getElementsByClassName('mpgooglemaps_map')[0].style.display = 'none';
}
</script>
<?php else: ?>
<div class="mpgooglemaps_review_map" style="float: left;width: 100%;margin: 15px 0;">
<?= /** @noEscape */ $block->getEmbedCode() ?>
</div>
<script type="text/javascript">
var position = '<?= $position ?>';
if (position === 'top') {
document.getElementsByClassName('mpgooglemaps_map')[1].style.display = 'none';
} else {
document.getElementsByClassName('mpgooglemaps_map')[0].style.display = 'none';
}
</script>
<?php endif; ?>
<?php endif; ?>
28 changes: 28 additions & 0 deletions view/frontend/templates/map/widget_position.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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_GoogleMaps
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

/** @var \Mageplaza\GoogleMaps\Helper\Data $helperData */
/** @var \Magento\Framework\View\Element\Template $block */
$helperData = $this->helper(\Mageplaza\GoogleMaps\Helper\Data::class);
$position = $helperData->getConfigGeneral('position');
if ($position == $block->getData('position')): ?>
<?= $block->getLayout()->createBlock(\Mageplaza\GoogleMaps\Block\Map::class)->toHtml() ?>
<?php endif; ?>

0 comments on commit 2cfdaef

Please sign in to comment.