Jump to content

Making a Navigation Folder Title a Clickthrough Link

Recommended Posts

  • Replies 13
  • Views 1.1k
  • Created
  • Last Reply

You will need to be on the business plan or above to implement this solution.

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 Settings > Advanced > Code Injection > FOOTER.

<script>

  $( ( ) => {
  
    $( '#main-navigation .folder-collection:first a:first' )
    
      .removeAttr ( 'onclick' )
      
      .attr ( 'href', '/accommodation' );
      
    } );
    
    $( '#main-navigation .folder-collection:nth-of-type(2) a:first' )
    
      .removeAttr ( 'onclick' )
      
      .attr ( 'href', '/resorts-choose' );
      
    } );
    
  </script>

This is for a v7.0 using the Five template.

Let us know how it goes.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment
On 9/28/2020 at 1:38 AM, tuanphan said:

Yes. Possible.

Can you share link to page where you use Stack images? We can check easier.

That's great thank you. It works for accommodation.

How can I change the code to work with the next navigation title, I want it to go to a page with the URL slug /resorts-choose?

 

Thanks.

Link to comment
  • 2 weeks later...

Hello there!

I'm having a problem with this too on my site. It's not live yet, but i'm trying to do the same as above but its not working for me. 

I've created a folder which i'd like to be called Directory and would like it to point to my /directory page. 

Would you please be able to help. I'm using the Artesia template.

Many thanks in advance!

Link to comment

@katie2203

Please post the URL to your site.

Please set up a site-wide password, if you've not already done so. Post the password here.

We can then take a look at your issue.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment

Hello @creedon! Thank you for your response. 

The URL is stalbans.thewearecommunity.co.uk password is help2021 and id like to make clicking on "directory" take you to the directory which is in the dropdown below it. So all you see is Directory on the title and Join Us below it as a dropdown.

Any help would be great! Many thanks in advance!

Katie

 

 

Link to comment
On 1/5/2021 at 7:14 PM, katie2203 said:

Hello @creedon! Thank you for your response. 

The URL is stalbans.thewearecommunity.co.uk password is help2021 and id like to make clicking on "directory" take you to the directory which is in the dropdown below it. So all you see is Directory on the title and Join Us below it as a dropdown.

Any help would be great! Many thanks in advance!

Katie

 

 

Add to Code Injection Footer

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
$(document).ready(function() { 
		$(".nav-item.folder:nth-child(3)").click(function() {
			var link = $(this).text(),
				href = "https://google.com";
			window.location.href=href;
		});
});
</script>

 

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!)

Link to comment
  • 3 weeks later...

@sibs

You will need to be on the business plan or above to implement this solution.

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 Settings > Advanced > Code Injection > FOOTER.

<script>

  $( ( ) => {
  
    // change navigation folder URL Slugs for v7.1 site
    
    const folderPositionUrlMappings = {
    
      /*
      
        the format of each line is the position of the folder in the navigation
        and the replacement URL Slug for the folder.
        
        */
        
      // '[enter position here]' : '[enter url here]',
      
      '1' : '/bewell',
      '2' : '/diversityindesign',
      '3' : '/begreen',
      '4' : '/events-full-page' // last or only item doesn't get a comma
      
      }
      
    // do not change anything below, there be the borg here
    
    const keys = Object.keys ( folderPositionUrlMappings );
    
    $.each ( keys, function ( i, key ) {
    
      $( '.header-nav-item--folder:nth-child(' + key + ') a:first' )
      
        .attr ( 'href', folderPositionUrlMappings [ key ] );
        
      } );
      
    } );
    
  </script>

This is for a v7.1.

Let us know how it goes.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment
  • 2 weeks later...

@SourMonkey

Please post the URL for your site.

If your site is not public please set up a site-wide password, if you've not already done so. Post the password here.

We can then take a look at your issue.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

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.