Skip to content

Commit

Permalink
Merge pull request #19 from Magenerds/seo-optimized-dialog
Browse files Browse the repository at this point in the history
Seo optimized dialog
  • Loading branch information
steinkopffp authored Jan 9, 2019
2 parents 5e6209c + 8eeda9d commit b3d8f22
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Block/Popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ public function hintedCountry()
'useDelay' => $this->config->useDelay(),
'delayDuration' => (int)$this->config->getDelayDuration(),
'cookieLifetime' => (int)$this->config->getCookieDuration(),
'modalContent' => $this->getModalText($lang, $this->getShowForUnselected())
'modalContent' => $this->getModalText($lang, $this->getShowForUnselected()),
'showModalOverlay' => $this->config->getShowModal()
];
}

Expand Down
21 changes: 19 additions & 2 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ class Config extends AbstractHelper
*/
const POPUP_DELAY_DURATION = 'countrypopup/popup_delay/delay_duration';

/**
* config path for show modal
*/
const SHOW_MODAL = 'countrypopup/general/show_modal';


/**
* fallback detect string
*/
Expand Down Expand Up @@ -174,7 +180,7 @@ public function getCountries($scope = ScopeInterface::SCOPE_STORE)
*/
public function homepageOnly($scope = ScopeInterface::SCOPE_STORE)
{
return boolval($this->scopeConfig->getValue(self::SHOW_ON_HOMEPAGE_ONLY, $scope));
return boolval($this->scopeConfig->isSetFlag(self::SHOW_ON_HOMEPAGE_ONLY, $scope));
}

/**
Expand All @@ -185,7 +191,7 @@ public function homepageOnly($scope = ScopeInterface::SCOPE_STORE)
*/
public function useDelay($scope = ScopeInterface::SCOPE_STORE)
{
return boolval($this->scopeConfig->getValue(self::USE_POPUP_DELAY, $scope));
return boolval($this->scopeConfig->isSetFlag(self::USE_POPUP_DELAY, $scope));
}

/**
Expand All @@ -198,4 +204,15 @@ public function getDelayDuration($scope = ScopeInterface::SCOPE_STORE)
{
return $this->scopeConfig->getValue(self::POPUP_DELAY_DURATION, $scope);
}

/**
* return true if show as modal dialog
*
* @param string $scope
* @return bool
*/
public function getShowModal($scope = ScopeInterface::SCOPE_STORE)
{
return $this->scopeConfig->isSetFlag(self::SHOW_MODAL, $scope);
}
}
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ The Magenerds Country PopUp config options a base under the point Magenerds -> C
#### General:

- **Enable:** Based on the selection the Module is enabled or disabled.
- **Use only on Homepage:** Option to show the modal only on homepage.
- **Cookie Duration:** Define Duration of the cookie in **days** empty or 0 is equal to session duration.
- **Enable:** Based on the selection the Module is enabled or disabled.
- **Use for Unselected Countries Text:** Option to show the modal for every visitor and shows the **Modaltext for Unselected Counties** if no country matches the selection of **Countries that should be hinted**.
- **Popup as modal dialog:** Show popup as modal dialog with overlay**.

#### County Modal Properties:

- **Countries that should be hinted:** This field provides the option to select the Countries that should be hinted.
- **Modaltext for Unselected Counties:** The Modaltext for Unselected Counties provides you a WYSIWYG-Editor that will be rendered inside of the Modal Content if **Use for Unselected Countries Text** is set on yes and if no country matches the selection of **Countries that should be hinted**
- **Modal Image Upload:** This field provides the option to display an image next to the Modaltext.
- **Dynamic Fields Modaltext for Country: Selected Country**: The Dynamic Fields will only be shown if a value in **Countries that should be hinted** is saved! Depending on the saved value an equal amount of WYSIWYG-Editorfields will be provided.
- **Dynamic Fields Modaltext for Country: Selected Country**: The Dynamic Fields will only be shown if a value in **Countries that should be hinted** is saved! Depending on the saved value an equal amount of WYSIWYG-Editorfields will be provided.

#### Popup delay options
- **Use Popup delay:** Based on the selection, the popup waits until it is displayed
- **Delay Duration:** Define the delay in milliseconds until the popup is displayed
15 changes: 10 additions & 5 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,23 @@
<label>Use only on Homepage</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="cookie" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="cookie" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Cookie Duration</label>
<validate>integer</validate>
<comment>Define Duration of the cookie in mm empty value is equal to session cookies</comment>
<comment> <![CDATA[Define Duration of the cookie <strong>in *days*</strong> empty or 0 is equal to session duration]]></comment>
<comment><![CDATA[Define Duration of the cookie <strong>in *days*</strong> empty or 0 is equal to session duration]]></comment>
</field>
<field id="unselected_countries_text" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Use for Unselected Countries Text</label>
<comment><![CDATA[If "Yes" is selected the default modaltext will be shown for all countries that are not selected <br /> If the detected country is equal the <strong>current store country</strong> no hint will be shown.]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="show_modal" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Popup as modal dialog</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Show dialog modal with overlay]]></comment>
</field>
</group>
<group id="popup_values" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>County Modal Properties</label>
Expand Down Expand Up @@ -81,10 +86,10 @@
<label>Use Popup delay</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="delay_duration" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="delay_duration" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Delay Duration</label>
<validate>integer</validate>
<comment>Define length of delay until the popup appears</comment>
<comment>Define length of delay in milliseconds until the popup appears</comment>
</field>
</group>
</section>
Expand Down
32 changes: 32 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<!--
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*/
/**
* @category Magenerds
* @package Magenerds_CountryPopUp
* @subpackage etc
* @author Martin Eisenführer <m.eisenfuehrer@techdivision.com>
* @copyright Copyright (c) 2019 TechDivision GmbH (http://www.techdivision.com)
* @link http://www.techdivision.com/
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<countrypopup>
<general>
<cookie>0</cookie>
<show_modal>1</show_modal>
</general>
<popup_delay>
<delay_duration>1000</delay_duration>
</popup_delay>
</countrypopup>
</default>
</config>
8 changes: 8 additions & 0 deletions view/frontend/web/css/language_popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
background: rgba(0, 0, 0, 0.5);
}

.hint-country-modal.no-overlay .modal-popup {
background: transparent;
}

.hint-country-modal.no-overlay .modals-overlay {
display: none;
}

#language-modal .img-wrapper {
flex-grow: 0;
flex-shrink: 0;
Expand Down
4 changes: 4 additions & 0 deletions view/frontend/web/js/country_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ define([
that.options.default_store = (response.defaultStore) ? response.defaultStore : false;
that.options.delay = (response.useDelay) ? response.delayDuration : 0;
that.options.cookie_lifetime = response.cookieLifetime;
that.options.show_modal_overlay = response.showModalOverlay;
that.prepareModal(response);
}
});
Expand Down Expand Up @@ -82,6 +83,9 @@ define([
if (!this.options.show_modal && !this.options.default_store) {
setTimeout(function () {
that.element.modal('openModal', true);
if (!that.options.show_modal_overlay) {
$('.hint-country-modal').addClass('no-overlay');
}
$.cookieStorage.setConf({
path: '/',
expires: parseInt(that.options.cookie_lifetime)
Expand Down

0 comments on commit b3d8f22

Please sign in to comment.