Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Customize BACK to All EVENTS URL


MM1

Question

Site URL: http://https/www.scienceseeds.com/

We are testing events for registration and have a general event page here:

https://www.scienceseeds.com/workshops-march

I saw Tuan's posting customize-back-to-all about how to change the back to all events text and redirect it. That works great for this page.

However, we have a second page

https://www.scienceseeds.com/test1

that has a calendar and a list of upcoming events. When you click on the event in the calendar or the event listing you get the full event description. When you click on "Back to All Events" we would like to return to the Calendar page and not to the main event page.

Is it possible to redirect to the test1 page in this case?

Link to post
  • Answers 5
  • Created
  • Last Reply

Top Posters For This Question

5 answers to this question

Recommended Posts

  • 0

Add to Settings > Advanced > Code Injection > Footer

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
	$('.eventitem-backlink').attr('href','https://beaverhero.com');
});
</script>

Replace with new url

Link to post
  • 0

Tuan - thank you . I tried that but that replaces the URL everywhere to the backlink URL. I want to be able to selectively choose the backlink based on the page that preceded it.

Link to post
  • 0
On 3/22/2021 at 8:15 AM, MM1 said:

Tuan - thank you . I tried that but that replaces the URL everywhere to the backlink URL. I want to be able to selectively choose the backlink based on the page that preceded it.

Add this to page header (page where you want to change url)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
	$('.eventitem-backlink').attr('href','https://beaverhero.com');
});
</script>

 

Link to post
  • 0

Hi Tuan,


That unfortunately doesn't work in this case. I need to capture the previous URL that got me to the events page and redirect to it. Is there a way to capture the window history and use that to set the backlink?

I have several paths that lead to the same events list so the backlink needs to remember the URL that got me there. The code above always sets the backlink to the same page.

Thanks!

Link to post
  • 0
Quote

I need to capture the previous URL that got me to the events page and redirect to it. Is there a way to capture the window history and use that to set the backlink?

In some cases yes. Unfortunately there are some circumstances where it won't work. Long story. Research on web if you are interested.

Add the following to Settings > Advanced > Code Injection > HEADER.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

Add the following to Event List Settings > Advanced > Page Header Code Injection for the Events page.

<script>

  $( ( ) => {
  
    /*
    
      change event back to all events link to back in some circumstances
      
      SS Version : 7.0
      
      Template   : Brine template family
      
      Notes      : the whole back thing is not perfect, i won't go into the long
                   and boring ins and outs of it but you can research on the web
                   if you are interested
      
      */
      
    if ( $( '.Main--events-item' ).length ) return;
    
    const referrer = document.referrer;
    
    if ( referrer ) {
    
      var $a = $( '<a>' )
      
        .attr ( 'href', referrer );
        
      if ( location.pathname.startsWith ( $a.prop ( 'pathname' ) ) ) return;
      
      }
      
    let $e = $( '.eventitem-backlink' )
    
      .text ( 'Back' );
      
    if ( referrer ) {
    
      $e.attr ( 'href', referrer )
      
      } else {
      
        $e
        
          .css ( 'cursor', 'pointer' )
          
          .removeAttr ( 'href' )
          
          .one ( 'click', function ( ) {
          
            history.back ( );
            
            } );
        }
        
    } );
    
  </script>

This is for v7.0 using the Brine template family.

Let us know how it goes.

Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support!

Link to post

Create an account or sign in to comment

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


×
×
  • Create New...