Jump to content

[Share] Click button - show different newsletter

Recommended Posts

Posted (edited)

If you have any problems or can't do this on your site, you can comment below or message me. I can help easier.

Suppose we need to create something like this, when users click on each button >> show corresponding newsletter block.

image.png.a9b9a5fc9b1c75cd302fd97e8e9263ed.png

 

#1. First, add 2 Button Blocks and 2 Newsletter Blocks

click-button-show-newsletter-01-min.png.20fa1ed17a9696c7d7f6d8909c204c60.png

#2. Edit 2 Button Blocks, and use these URLs:

  • #forbuyer
  • #forseller

and make sure the option “Open Link in New Tab” is disabled.

image.png.b09bb8a78fb04cdd1c0476e941c4e9d2.png

image.png.92ee9a7cf81655222758773419c29a10.png

#3. Install this free tool to find ID of 2 Newsletter Blocks

https://chromewebstore.google.com/detail/squarespace-id-finder/igjamfnifnkmecjidfbdipieoaeghcff

In my example, we will have

  • Newsletter 1: #block-7410df8c50a7724d4fcc
  • Newsletter 2: #block-3b3a7f22b741c66555b9

image.png.3628cf78bed3ce98fb9b7669d81ae96a.png

#4. Use this code to Code Injection > Footer (or Page Header Code Injection, page where you use 2 Newsletter Blocks)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
  // For Buyer 
  $("#block-7410df8c50a7724d4fcc").closest('.fe-block').addClass('forbuyer show');
    $('a[href="#forbuyer"]').addClass('active-button');
  // For Seller
$("#block-3b3a7f22b741c66555b9").closest('.fe-block').addClass('forseller');
  
  // For Buyer 
  $('a[href="#forbuyer"]').click(function(){
    $(".forbuyer").addClass("show");
    $('.fe-block:not(.forbuyer)').removeClass('show');
    $(this).addClass('active-button');
    $('a:not([href="#forbuyer"])').removeClass('active-button');
    }
  );
// For Seller
 $('a[href="#forseller"]').click(function(){
   $(".forseller").addClass("show");
    $('.fe-block:not(.forseller)').removeClass('show');
    $(this).addClass('active-button');
    $('a:not([href="#forseller"])').removeClass('active-button')
    }
  );
});
</script>
<style>
.forbuyer .newsletter-block, .forseller .newsletter-block {
    display: none;
}
  .show .newsletter-block {
      display: block !important;
  }
  .show {
      z-index: 999999 !important;
  }
  .active-button {
  background-color: green !important;
  }
</style>

#5. Adjust some style

If you want to change Button Style to Checkbox like this

image.png.a9b9a5fc9b1c75cd302fd97e8e9263ed.png

Use this code to Website Tools > Custom CSS

a[href="#forbuyer"]:before, a[href="#forseller"]:before {
    content: "\f0c8";
    font-family: "Font Awesome 6 Free";
    font-weight: bold;
    font-size: 20px;
    color: #000 !important;
	 margin-right: 5px;
    font-weight: 400;
}
a[href="#forbuyer"], a[href="#forseller"] {
    background-color: transparent !important;
    color: #000 !important;
}
.active-button:before {
    content: "\f14a" !important;
}

 

Edited by tuanphan
fix js code

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

  • 2 months later...
Posted

Hi tuanphan!

I have been searching to adjust the size of the sign-up button in the newsletter block ( I've already adjusted the primary button in the site styles). When I edited the button sizes globally - it did not affect the newsletter block button.  Very frustrating! 

I have uploaded screenshots. 

Could CSS code help me resize that sign-up button to match the other sized buttons on the website? 

https://bumblebee-orb-p4mf.squarespace.com/stay-in-the-loop

password: ICAN

 

Screenshot 2024-07-26 at 9.22.13 AM.png

Screenshot 2024-07-26 at 9.22.43 AM.png

Posted
7 hours ago, KoriLinaeC said:

Hi tuanphan!

I have been searching to adjust the size of the sign-up button in the newsletter block ( I've already adjusted the primary button in the site styles). When I edited the button sizes globally - it did not affect the newsletter block button.  Very frustrating! 

I have uploaded screenshots. 

Could CSS code help me resize that sign-up button to match the other sized buttons on the website? 

https://bumblebee-orb-p4mf.squarespace.com/stay-in-the-loop

password: ICAN

 

Screenshot 2024-07-26 at 9.22.13 AM.png

Screenshot 2024-07-26 at 9.22.43 AM.png

You can use this code to Custom CSS box

button.newsletter-form-button.sqs-system-button {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    padding-left: 40px !important;
    padding-right: 40px !important;
}
span.newsletter-form-button-label {
    font-size: 16px !important;
}

image.png.5a0b200c92d85843fd79d74b62b4aa4d.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

  • 3 weeks later...
  • 3 months later...
Posted (edited)

Hi Tuanphan,

I want to add this to a web page on my website. I've already got it in my website footer, but when I direct people to sign up I want them to go to a page. Can I enter the code I entered into Code Injection > Footer into the Custom CSS section or will it not work? Not sure if that code is only suitable for the footer / header only. Any help would be greatly appreciated. I assume I'd need to somehow direct it to the specific page I want it to be on, so it's not effecting the whole website. It's working perfectly in my footer, just need to make it work on a web page now. Thank you, Charli 

Edited by CharliSavage

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.