Jump to content

Can I link a folder to a specific page?

Recommended Posts

As brought up here: http://answers.squarespace.com/questions/8532/folder-navigation-top-folder-doesnt-link-to-anything-can-i-get-it-to-or-remove-link-behavior

Folders should have a click through link so that it can be clicked to go to another page. It should work the same as a regular folder in that it should still have an active colour if that has been set so that if you are on a page that is held within that folder or the page the folder link is connected to the "active color" works.

Please vote up if you agree.

Another possible option is to make a special kind of page that works like a folder in that anything placed under it shows up in navigation as a drop down but it is also a normal page and can have content on it. That would save having to create a special no linked page that works with the pass through. Maybe have a check box or such for people that want it to just act like a normal Folder.

Link to comment
  • 1 year later...
  • Replies 38
  • Views 19.6k
  • Created
  • Last Reply

You can do this with a bit of JavaScript hackery. Here is some code to do it using jQuery, let’s say you had a folder called “Donate Now” that contained links to other ways to donate, but if you wanted the user to be able to click the folder directly you could add to your header code injection:


<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(function() {
 $('.main-nav li a').each(function () {
   if ($(this).text() == 'Donate Now') {
       $(this).attr('href','http://www.paypal.com');
   }
 });
});
</script>

That would search through your main navigation links, find the one named “Donate Now”, and change the link from nothing to, PayPal in this example, put whatever you want there.

Cheers,Forrest (cloudyreason.com)

Link to comment

You can add a line that says :


$(this).attr('onclick','true');

after the attr('href') line, that will fix it. So:


<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(function() {
 $('.main-nav li a').each(function () {
   if ($(this).text() == 'Donate Now') {
       $(this).attr('href','http://www.paypal.com');
       $(this).attr('onclick','true');
   }
 });
});
</script>

Make sure the 'Donate Now' is the exact same text as in the HTML, capitalization matters.

Best,Forrest (cloudyreason.com)

Link to comment
  • 2 months later...

This JavaScript works great for me in the desktop mode of the Wexley template.Instead of 'PayPal' the folder links to a gallery page ('/food/') which is placed in the "Not Linked-Section" – but in the mobile view this clickable folder is not displayed in the mobile menu. I need that folder beeing part of the mobile menu as well. Any ideas how to fix that?

Link to comment

This html goes in Settings / Advanced / Code Injection / Header...
And it works. Add more sections if you have more folders to include.


}
if ($(this).text() == 'Folder 2') {
   $(this).attr('href','http://www.page2');
   $(this).attr('onclick','true');

Link to comment
  • 3 weeks later...

You must be sure you are injecting this into the HEADER CODE INJECTOR space for HTML. This is not CSS.

To find this space, go to the editing pane where there is a list on the left that starts with PAGES and ends with HELP. Just above Help is the SETTINGS link. Click that, then Advanced, then Code Injector. The Header window injection place should be at the top of the that section.

Link to comment

Last try:


<!-- makes navigation folder a clickable link -->
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(function() {
 $('.main-nav li a').each(function () {
   if ($(this).text() == 'FolderName') {
       $(this).attr('href','http://www.TargetWebPage');
       $(this).attr('onclick','true');
   }
 });
 });
</script>



Link to comment

OK. Finally. This is what you paste into the Header Code Injector. Replace FolderName and TargetWebPage with your info. The first line with the < ... > is only a note and will not affect coding if deleted.

You can add more folder actions by adding the following code after the last single } .

Link to comment

Hi jpwv. Thanks for your reiterations. I appreciate your help, even though following instructions was not my problem.

I was having a very frustrating time. I was doing it right EXCEPT when I cut and pasted into a text editor, it was converting into smart quotes. D'oh! When I fixed those it now works beautifully!

Link to comment

No experience with Dovetail. All I can think of is to be sure you are putting this into the HEADER INJECTOR, not the CSS injector. Be sure you capitalize your folder name in exactly the same way you use it in the header. Also be sure the target URL is exactly correct as well.

Link to comment

Be sure you copy the code exactly and do not delete any of the ' marks when you copy your links into it. I suggest making the changes in a text editing window and pasting that into the Header Code Injector. Be sure you are not working on a single page, but the whole site.

Link to comment

Archived

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

Guest
This topic is now 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.