Jump to content

Change event back button behavior and text when multiple event pages are in use

Recommended Posts

Site URL: https://springtail-pufferfish-lyy6.squarespace.com/

Password for site entry: repair2021

I've used some code from @tuanphan to customize the behavior of an event back button. The code changes "Back to events" to "Back to listings" and also redirects to a particular page. 

The issue I'm having is that I have two separate events pages — one being used as a directory and the other being used as intended. I would like the wording and page redirect to be independent for each page. How do I achieve this?

The behavior is working correctly for this page:
https://springtail-pufferfish-lyy6.squarespace.com/board-listings


But needs to be altered for this page:
https://springtail-pufferfish-lyy6.squarespace.com/events

 

Here's the code I'm using:

<!-- Change board listing back button behavior -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
jQuery(function($){
    $(".eventitem-backlink").html(function() { 
          return $(this).html().replace("Back to All Events", "Back to listings");  
    });
  $('.eventitem-backlink').attr('href','/board-listings');
});
</script>
<!-- end Change board listing back button behavior -->

I would greatly appreciate any help on this!

Link to comment
  • Replies 4
  • Views 433
  • Created
  • Last Reply
On 5/18/2021 at 11:28 AM, BFGS said:

Site URL: https://springtail-pufferfish-lyy6.squarespace.com/

Password for site entry: repair2021

I've used some code from @tuanphan to customize the behavior of an event back button. The code changes "Back to events" to "Back to listings" and also redirects to a particular page. 

The issue I'm having is that I have two separate events pages — one being used as a directory and the other being used as intended. I would like the wording and page redirect to be independent for each page. How do I achieve this?

The behavior is working correctly for this page:
https://springtail-pufferfish-lyy6.squarespace.com/board-listings


But needs to be altered for this page:
https://springtail-pufferfish-lyy6.squarespace.com/events

 

Here's the code I'm using:


<!-- Change board listing back button behavior -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
jQuery(function($){
    $(".eventitem-backlink").html(function() { 
          return $(this).html().replace("Back to All Events", "Back to listings");  
    });
  $('.eventitem-backlink').attr('href','/board-listings');
});
</script>
<!-- end Change board listing back button behavior -->

I would greatly appreciate any help on this!

Try

<!-- Change board listing back button behavior -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
jQuery(function($){
  	if (window.location.pathname.split('/')[1] == "board-listings") {
    	$(".eventitem-backlink").html(function() { 
              return $(this).html().replace("Back to All Events", "Back to listings");  
        });
        $('.eventitem-backlink').attr('href','/board-listings');
    }    
});
</script>
<!-- end Change board listing back button behavior -->

this will affect on board listings only

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

@bangank36 — thank you for your help. I've inserted your code and it is not working for me. It's now returned to "Back to all events" for both events pages that I'm using + the routing via eventitem-backlink is not working / directing to the correct page.

Link to comment
35 minutes ago, BFGS said:

@bangank36 — thank you for your help. I've inserted your code and it is not working for me. It's now returned to "Back to all events" for both events pages that I'm using + the routing via eventitem-backlink is not working / directing to the correct page.

i misread, change the string to "board-postings" to make it work

<!-- Change board listing back button behavior -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
jQuery(function($){
  	if (window.location.pathname.split('/')[1] == "board-postings") {
    	$(".eventitem-backlink").html(function() { 
              return $(this).html().replace("Back to All Events", "Back to listings");  
        });
        $('.eventitem-backlink').attr('href','/board-listings');
    }    
});
</script>
<!-- end Change board listing back button behavior -->

 

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.