Magento 2 newsletter popup disable for mobile [on hold]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I have modified the content of the newsletter popup in my magento 2 site with porto theme enabled. I was able to update the content from the Admin>configuration>porto>setting



But I want the popup to become disable when the screenwidth of the device is less than 1600.



This is the full length of the phtml file:



<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

?>
<?php
$_helper = $this->helper('SmartwavePortoHelperData');

$popup = $_helper->getConfig('porto_settings/newsletter');
if($popup['enable']) {

$delay = $popup["delay"];
?>
if ($screenWidth >1600) {

<script type="text/javascript">
require([
'jquery',
'jquery/jquery.cookie'
], function ($) {
$(document).ready(function(){
<?php if($popup['enable'] == 1): ?>
if($("body").hasClass("cms-index-index")) {
<?php endif; ?>
var check_cookie = $.cookie('newsletter_popup');
if(window.location!=window.parent.location){
$('#newsletter_popup').remove();
} else {
if(check_cookie == null || check_cookie == 'shown') {
setTimeout(function(){
beginNewsletterForm();
}, <?php echo $delay; ?>);
}
/* if($.cookie('newsletter_popup') == 'dontshowitagain'){
$('#newsletter_popup').hide();
} else {*/
$('#footer_newsletter').on('change', function(){
if($(this).length){
var check_cookie = $.cookie('newsletter_popup');
if(check_cookie == null || check_cookie == 'shown') {
$.cookie('newsletter_popup','dontshowitagain');
}
else
{
$.cookie('newsletter_popup','shown');
beginNewsletterForm();
}
} else {
$.cookie('newsletter_popup','shown');
}
});
$("close-button").click()
{
$.cookie('newsletter_popup','dontshowitagain');
}
// }
}
<?php if($popup['enable'] == 1): ?>
}
<?php endif; ?>
});

function beginNewsletterForm() {
$.fancybox({
'padding': '0px',
'autoScale': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'inline',
'href': '#newsletter_popup',
'onComplete': function() {
$.cookie('newsletter_popup', 'shown');
},
'tpl': {
closeBtn: '<a id="close-button "title="Close" class="fancybox-item fancybox-close fancybox-newsletter-close" href="javascript:;"></a>'
},
'helpers': {
overlay: {
locked: false
}
}
});
$('#newsletter_popup').trigger('click');
}
});
</script>
<style type="text/css">
<?php
if($popup["custom_style"]){
echo $popup["custom_style"];
}
?>
#newsletter_popup
{
<?php
if($popup["width"]){
echo "width:".$popup["width"].";";
}
if($popup["height"]){
echo "height:".$popup["height"].";";
}
if($popup["bg_color"]){
echo "background-color:".$popup["bg_color"].";";
}

if(isset($popup["bg_image"]) && $popup["bg_image"]){
$folderName = SmartwavePortoModelConfigBackendImageNewsletterbg::UPLOAD_DIR;
$path = $folderName . '/' . $popup["bg_image"];
$imageUrl = $_helper->getBaseUrl() . $path;
?>
background-image:url(<?php echo $imageUrl;?>);
<?php
}
?>
}
</style>
<div class="newsletter" id="newsletter_popup" style="display: none;">
<div class="block-content" >
<?php
if(isset($popup["logo_src"]) && $popup["logo_src"]){
$folderName = SmartwavePortoModelConfigBackendImageNewsletterlogo::UPLOAD_DIR;
$path = $folderName . '/' . $popup["logo_src"];
$logoUrl = $_helper->getBaseUrl() . $path;
?>
<img src="<?php echo $logoUrl; ?>" alt="" />
<?php
}
?>
<?php echo $popup["content"]; ?>
<form class="form subscribe"
novalidate
action="<?php echo $block->getFormActionUrl() ?>"
method="post"
data-mage-init='{"validation": {"errorClass": "mage-error"}}'
id="newsletter-validate-detail">
<!--
<div class="field newsletter">
<div class="control">
<input name="email" type="email" id="footer_newsletter"
data-validate="{required:true, 'validate-email':true}"/>
</div>
</div>
<div class="actions">
<button class="action subscribe primary" title="<?php echo __('Go') ?>" type="submit">
<span><?php echo __('Go') ?></span>

</div> -->
</form>
<div class="subscribe-bottom">
<input type="checkbox" value="dontshowitagain" id="newsletter_popup_dont_show_again" style="display: none;" />
<!-- <label for="newsletter_popup_dont_show_again"><?php echo __("Don't show this popup again"); ?></label> -->
</div>
</div>
</div>
<?php
}

?>


I was trying to use the following variable:



$screenWidth = '<script type="text/javascript">document.write(screen.availWidth);</script>';


but not sure how to do that. Any other method is also appreciated.
Thank you










share|improve this question















put on hold as off-topic by Amit Bera 13 mins ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about third-party modules are generally off-topic because the scope of functionality and code are not available. For more information, see this meta post/answer." – Amit Bera

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • Hi Amit, I have reworded the question. Hope this is correct now. Highly appreciate your help

    – ishu
    7 mins ago


















1















I have modified the content of the newsletter popup in my magento 2 site with porto theme enabled. I was able to update the content from the Admin>configuration>porto>setting



But I want the popup to become disable when the screenwidth of the device is less than 1600.



This is the full length of the phtml file:



<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

?>
<?php
$_helper = $this->helper('SmartwavePortoHelperData');

$popup = $_helper->getConfig('porto_settings/newsletter');
if($popup['enable']) {

$delay = $popup["delay"];
?>
if ($screenWidth >1600) {

<script type="text/javascript">
require([
'jquery',
'jquery/jquery.cookie'
], function ($) {
$(document).ready(function(){
<?php if($popup['enable'] == 1): ?>
if($("body").hasClass("cms-index-index")) {
<?php endif; ?>
var check_cookie = $.cookie('newsletter_popup');
if(window.location!=window.parent.location){
$('#newsletter_popup').remove();
} else {
if(check_cookie == null || check_cookie == 'shown') {
setTimeout(function(){
beginNewsletterForm();
}, <?php echo $delay; ?>);
}
/* if($.cookie('newsletter_popup') == 'dontshowitagain'){
$('#newsletter_popup').hide();
} else {*/
$('#footer_newsletter').on('change', function(){
if($(this).length){
var check_cookie = $.cookie('newsletter_popup');
if(check_cookie == null || check_cookie == 'shown') {
$.cookie('newsletter_popup','dontshowitagain');
}
else
{
$.cookie('newsletter_popup','shown');
beginNewsletterForm();
}
} else {
$.cookie('newsletter_popup','shown');
}
});
$("close-button").click()
{
$.cookie('newsletter_popup','dontshowitagain');
}
// }
}
<?php if($popup['enable'] == 1): ?>
}
<?php endif; ?>
});

function beginNewsletterForm() {
$.fancybox({
'padding': '0px',
'autoScale': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'inline',
'href': '#newsletter_popup',
'onComplete': function() {
$.cookie('newsletter_popup', 'shown');
},
'tpl': {
closeBtn: '<a id="close-button "title="Close" class="fancybox-item fancybox-close fancybox-newsletter-close" href="javascript:;"></a>'
},
'helpers': {
overlay: {
locked: false
}
}
});
$('#newsletter_popup').trigger('click');
}
});
</script>
<style type="text/css">
<?php
if($popup["custom_style"]){
echo $popup["custom_style"];
}
?>
#newsletter_popup
{
<?php
if($popup["width"]){
echo "width:".$popup["width"].";";
}
if($popup["height"]){
echo "height:".$popup["height"].";";
}
if($popup["bg_color"]){
echo "background-color:".$popup["bg_color"].";";
}

if(isset($popup["bg_image"]) && $popup["bg_image"]){
$folderName = SmartwavePortoModelConfigBackendImageNewsletterbg::UPLOAD_DIR;
$path = $folderName . '/' . $popup["bg_image"];
$imageUrl = $_helper->getBaseUrl() . $path;
?>
background-image:url(<?php echo $imageUrl;?>);
<?php
}
?>
}
</style>
<div class="newsletter" id="newsletter_popup" style="display: none;">
<div class="block-content" >
<?php
if(isset($popup["logo_src"]) && $popup["logo_src"]){
$folderName = SmartwavePortoModelConfigBackendImageNewsletterlogo::UPLOAD_DIR;
$path = $folderName . '/' . $popup["logo_src"];
$logoUrl = $_helper->getBaseUrl() . $path;
?>
<img src="<?php echo $logoUrl; ?>" alt="" />
<?php
}
?>
<?php echo $popup["content"]; ?>
<form class="form subscribe"
novalidate
action="<?php echo $block->getFormActionUrl() ?>"
method="post"
data-mage-init='{"validation": {"errorClass": "mage-error"}}'
id="newsletter-validate-detail">
<!--
<div class="field newsletter">
<div class="control">
<input name="email" type="email" id="footer_newsletter"
data-validate="{required:true, 'validate-email':true}"/>
</div>
</div>
<div class="actions">
<button class="action subscribe primary" title="<?php echo __('Go') ?>" type="submit">
<span><?php echo __('Go') ?></span>

</div> -->
</form>
<div class="subscribe-bottom">
<input type="checkbox" value="dontshowitagain" id="newsletter_popup_dont_show_again" style="display: none;" />
<!-- <label for="newsletter_popup_dont_show_again"><?php echo __("Don't show this popup again"); ?></label> -->
</div>
</div>
</div>
<?php
}

?>


I was trying to use the following variable:



$screenWidth = '<script type="text/javascript">document.write(screen.availWidth);</script>';


but not sure how to do that. Any other method is also appreciated.
Thank you










share|improve this question















put on hold as off-topic by Amit Bera 13 mins ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about third-party modules are generally off-topic because the scope of functionality and code are not available. For more information, see this meta post/answer." – Amit Bera

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • Hi Amit, I have reworded the question. Hope this is correct now. Highly appreciate your help

    – ishu
    7 mins ago














1












1








1








I have modified the content of the newsletter popup in my magento 2 site with porto theme enabled. I was able to update the content from the Admin>configuration>porto>setting



But I want the popup to become disable when the screenwidth of the device is less than 1600.



This is the full length of the phtml file:



<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

?>
<?php
$_helper = $this->helper('SmartwavePortoHelperData');

$popup = $_helper->getConfig('porto_settings/newsletter');
if($popup['enable']) {

$delay = $popup["delay"];
?>
if ($screenWidth >1600) {

<script type="text/javascript">
require([
'jquery',
'jquery/jquery.cookie'
], function ($) {
$(document).ready(function(){
<?php if($popup['enable'] == 1): ?>
if($("body").hasClass("cms-index-index")) {
<?php endif; ?>
var check_cookie = $.cookie('newsletter_popup');
if(window.location!=window.parent.location){
$('#newsletter_popup').remove();
} else {
if(check_cookie == null || check_cookie == 'shown') {
setTimeout(function(){
beginNewsletterForm();
}, <?php echo $delay; ?>);
}
/* if($.cookie('newsletter_popup') == 'dontshowitagain'){
$('#newsletter_popup').hide();
} else {*/
$('#footer_newsletter').on('change', function(){
if($(this).length){
var check_cookie = $.cookie('newsletter_popup');
if(check_cookie == null || check_cookie == 'shown') {
$.cookie('newsletter_popup','dontshowitagain');
}
else
{
$.cookie('newsletter_popup','shown');
beginNewsletterForm();
}
} else {
$.cookie('newsletter_popup','shown');
}
});
$("close-button").click()
{
$.cookie('newsletter_popup','dontshowitagain');
}
// }
}
<?php if($popup['enable'] == 1): ?>
}
<?php endif; ?>
});

function beginNewsletterForm() {
$.fancybox({
'padding': '0px',
'autoScale': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'inline',
'href': '#newsletter_popup',
'onComplete': function() {
$.cookie('newsletter_popup', 'shown');
},
'tpl': {
closeBtn: '<a id="close-button "title="Close" class="fancybox-item fancybox-close fancybox-newsletter-close" href="javascript:;"></a>'
},
'helpers': {
overlay: {
locked: false
}
}
});
$('#newsletter_popup').trigger('click');
}
});
</script>
<style type="text/css">
<?php
if($popup["custom_style"]){
echo $popup["custom_style"];
}
?>
#newsletter_popup
{
<?php
if($popup["width"]){
echo "width:".$popup["width"].";";
}
if($popup["height"]){
echo "height:".$popup["height"].";";
}
if($popup["bg_color"]){
echo "background-color:".$popup["bg_color"].";";
}

if(isset($popup["bg_image"]) && $popup["bg_image"]){
$folderName = SmartwavePortoModelConfigBackendImageNewsletterbg::UPLOAD_DIR;
$path = $folderName . '/' . $popup["bg_image"];
$imageUrl = $_helper->getBaseUrl() . $path;
?>
background-image:url(<?php echo $imageUrl;?>);
<?php
}
?>
}
</style>
<div class="newsletter" id="newsletter_popup" style="display: none;">
<div class="block-content" >
<?php
if(isset($popup["logo_src"]) && $popup["logo_src"]){
$folderName = SmartwavePortoModelConfigBackendImageNewsletterlogo::UPLOAD_DIR;
$path = $folderName . '/' . $popup["logo_src"];
$logoUrl = $_helper->getBaseUrl() . $path;
?>
<img src="<?php echo $logoUrl; ?>" alt="" />
<?php
}
?>
<?php echo $popup["content"]; ?>
<form class="form subscribe"
novalidate
action="<?php echo $block->getFormActionUrl() ?>"
method="post"
data-mage-init='{"validation": {"errorClass": "mage-error"}}'
id="newsletter-validate-detail">
<!--
<div class="field newsletter">
<div class="control">
<input name="email" type="email" id="footer_newsletter"
data-validate="{required:true, 'validate-email':true}"/>
</div>
</div>
<div class="actions">
<button class="action subscribe primary" title="<?php echo __('Go') ?>" type="submit">
<span><?php echo __('Go') ?></span>

</div> -->
</form>
<div class="subscribe-bottom">
<input type="checkbox" value="dontshowitagain" id="newsletter_popup_dont_show_again" style="display: none;" />
<!-- <label for="newsletter_popup_dont_show_again"><?php echo __("Don't show this popup again"); ?></label> -->
</div>
</div>
</div>
<?php
}

?>


I was trying to use the following variable:



$screenWidth = '<script type="text/javascript">document.write(screen.availWidth);</script>';


but not sure how to do that. Any other method is also appreciated.
Thank you










share|improve this question
















I have modified the content of the newsletter popup in my magento 2 site with porto theme enabled. I was able to update the content from the Admin>configuration>porto>setting



But I want the popup to become disable when the screenwidth of the device is less than 1600.



This is the full length of the phtml file:



<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

?>
<?php
$_helper = $this->helper('SmartwavePortoHelperData');

$popup = $_helper->getConfig('porto_settings/newsletter');
if($popup['enable']) {

$delay = $popup["delay"];
?>
if ($screenWidth >1600) {

<script type="text/javascript">
require([
'jquery',
'jquery/jquery.cookie'
], function ($) {
$(document).ready(function(){
<?php if($popup['enable'] == 1): ?>
if($("body").hasClass("cms-index-index")) {
<?php endif; ?>
var check_cookie = $.cookie('newsletter_popup');
if(window.location!=window.parent.location){
$('#newsletter_popup').remove();
} else {
if(check_cookie == null || check_cookie == 'shown') {
setTimeout(function(){
beginNewsletterForm();
}, <?php echo $delay; ?>);
}
/* if($.cookie('newsletter_popup') == 'dontshowitagain'){
$('#newsletter_popup').hide();
} else {*/
$('#footer_newsletter').on('change', function(){
if($(this).length){
var check_cookie = $.cookie('newsletter_popup');
if(check_cookie == null || check_cookie == 'shown') {
$.cookie('newsletter_popup','dontshowitagain');
}
else
{
$.cookie('newsletter_popup','shown');
beginNewsletterForm();
}
} else {
$.cookie('newsletter_popup','shown');
}
});
$("close-button").click()
{
$.cookie('newsletter_popup','dontshowitagain');
}
// }
}
<?php if($popup['enable'] == 1): ?>
}
<?php endif; ?>
});

function beginNewsletterForm() {
$.fancybox({
'padding': '0px',
'autoScale': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'inline',
'href': '#newsletter_popup',
'onComplete': function() {
$.cookie('newsletter_popup', 'shown');
},
'tpl': {
closeBtn: '<a id="close-button "title="Close" class="fancybox-item fancybox-close fancybox-newsletter-close" href="javascript:;"></a>'
},
'helpers': {
overlay: {
locked: false
}
}
});
$('#newsletter_popup').trigger('click');
}
});
</script>
<style type="text/css">
<?php
if($popup["custom_style"]){
echo $popup["custom_style"];
}
?>
#newsletter_popup
{
<?php
if($popup["width"]){
echo "width:".$popup["width"].";";
}
if($popup["height"]){
echo "height:".$popup["height"].";";
}
if($popup["bg_color"]){
echo "background-color:".$popup["bg_color"].";";
}

if(isset($popup["bg_image"]) && $popup["bg_image"]){
$folderName = SmartwavePortoModelConfigBackendImageNewsletterbg::UPLOAD_DIR;
$path = $folderName . '/' . $popup["bg_image"];
$imageUrl = $_helper->getBaseUrl() . $path;
?>
background-image:url(<?php echo $imageUrl;?>);
<?php
}
?>
}
</style>
<div class="newsletter" id="newsletter_popup" style="display: none;">
<div class="block-content" >
<?php
if(isset($popup["logo_src"]) && $popup["logo_src"]){
$folderName = SmartwavePortoModelConfigBackendImageNewsletterlogo::UPLOAD_DIR;
$path = $folderName . '/' . $popup["logo_src"];
$logoUrl = $_helper->getBaseUrl() . $path;
?>
<img src="<?php echo $logoUrl; ?>" alt="" />
<?php
}
?>
<?php echo $popup["content"]; ?>
<form class="form subscribe"
novalidate
action="<?php echo $block->getFormActionUrl() ?>"
method="post"
data-mage-init='{"validation": {"errorClass": "mage-error"}}'
id="newsletter-validate-detail">
<!--
<div class="field newsletter">
<div class="control">
<input name="email" type="email" id="footer_newsletter"
data-validate="{required:true, 'validate-email':true}"/>
</div>
</div>
<div class="actions">
<button class="action subscribe primary" title="<?php echo __('Go') ?>" type="submit">
<span><?php echo __('Go') ?></span>

</div> -->
</form>
<div class="subscribe-bottom">
<input type="checkbox" value="dontshowitagain" id="newsletter_popup_dont_show_again" style="display: none;" />
<!-- <label for="newsletter_popup_dont_show_again"><?php echo __("Don't show this popup again"); ?></label> -->
</div>
</div>
</div>
<?php
}

?>


I was trying to use the following variable:



$screenWidth = '<script type="text/javascript">document.write(screen.availWidth);</script>';


but not sure how to do that. Any other method is also appreciated.
Thank you







magento2 newsletter popup






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 mins ago









Savan Patel

11412




11412










asked 13 mins ago









ishuishu

234




234




put on hold as off-topic by Amit Bera 13 mins ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about third-party modules are generally off-topic because the scope of functionality and code are not available. For more information, see this meta post/answer." – Amit Bera

If this question can be reworded to fit the rules in the help center, please edit the question.







put on hold as off-topic by Amit Bera 13 mins ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about third-party modules are generally off-topic because the scope of functionality and code are not available. For more information, see this meta post/answer." – Amit Bera

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Hi Amit, I have reworded the question. Hope this is correct now. Highly appreciate your help

    – ishu
    7 mins ago



















  • Hi Amit, I have reworded the question. Hope this is correct now. Highly appreciate your help

    – ishu
    7 mins ago

















Hi Amit, I have reworded the question. Hope this is correct now. Highly appreciate your help

– ishu
7 mins ago





Hi Amit, I have reworded the question. Hope this is correct now. Highly appreciate your help

– ishu
7 mins ago










0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Last logged in always never, not logging

Iĥnotaksono

Colouring column values based on a specific condition. How could I do this?