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

Automatically display text when summary block is empty


alicroft

Question

I've tried every solution I could find here on the Circle forum, but none are working!

page: https://theveil.squarespace.com/nfk
(scroll down to "Upcoming Events" section)

template: Royce

I've got a Summary Block displaying Events, filtered by Category. When nothing matches the filter criteria, there is just a big black space on the page. I'd prefer it to automatically display text when the summary block is empty, like

"There are no upcoming events at this location."

Note: The Upcoming Events section on the page is actually a page (/nfk-events) nestled within an Index Collection (/nfk), in case it matters.

Anyone have ideas / updates to the old solutions for this? (https://forum.squarespace.com/search/?&q=empty summary block&search_and_or=and&sortby=relevancy)

Screen Shot 2019-11-11 at 20.17.50.png

Edited by alicroft
add detail
Link to comment

18 answers to this question

Recommended Posts

  • 1

Hi @alicroft

The solution that I provided in March 2018 still works if the template doesn't use Ajax or if it is disabled.

It's an old answer, so if you have Ajax enabled, you'll need to replace the domready function with onInitialize instead:

<script>
window.Squarespace.onInitialize(Y, function(){ 
  var summaryExists = document.getElementsByClassName("summary-title")[0];
  if (summaryExists == null) { 
    document.getElementById('no-events').innerHTML = "There are no upcoming events at this location.";
  }
}); 
</script>

 

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment
  • 0

To be clear, the code won't work in the page header injection of either of these if you have Ajax enabled.

(Note that Ajax is never enabled when you are logged on to a site! This makes it appear to work whilst logged on, but as soon as you hand over a site and the client tries it, they'll find it doesn't work 😫

If further checks are added to the code to identify the collection or URL it can then be inserted in the Footer Injection and it will play nice with Ajax 🙂.

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment
  • 0

@paul2009 I have Ajax enabled, and inserted your code as written above into the Collection's header injection, and it's working...!

Is this delicate in some way? (I know nothing about Ajax or javascript!) Should I move it into the Footer Injection area of the site instead? I'd prefer to leave it on the Collection so I can customize what it says for each summary block on the site, if possible.

Link to comment
  • 1

It will only work if you are logged on, or if you load that specific page. If you navigate from another page to that one, it won't. 

 

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment
  • 0

I wrote a guide that may help you to understand how Ajax affects JavaScript on Squarespace:

https://sf.digital/squarespace-solutions/why-doesnt-my-code-work-until-i-refresh-the-page

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment
  • 0
1 minute ago, Ida_nymand said:

I'm unable to see the answer, you provided. Do you know why that is?

You can't see the original post because Squarespace upgraded their forum and deleted lots of content. However, I had repeated the answer below the link (as shown in your screenshot 🙂).

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment
  • 0

Thanks, I thought that was in relation to disabling Ajax, haha.  I've tried to insert the code in my Index page header injection, but it doesn't seem to be working. I don't have Ajax enabled.

I'm using the Stella template - do you think this might be why it's not working? 

 

Link to comment
  • 0
2 hours ago, Ida_nymand said:

I'm using the Stella template - do you think this might be why it's not working? 

Stella is a Brine-family template, so it should be fine. The code needs to be inserted in the site footer injection area. (Settings > Advanced > Code Injection). If it doesn't work for you, please post a working link to the page.

 

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment
  • 0
16 hours ago, paul2009 said:

Stella is a Brine-family template, so it should be fine. The code needs to be inserted in the site footer injection area. (Settings > Advanced > Code Injection). If it doesn't work for you, please post a working link to the page.

 

I tried to insert the code in the site footer injection area, but it's still not working. Would be great if you would take a look at it. Link to the page: https://www.rumligcph.dk/hjem 

The Summary Block is located under the 'Events' headline. 

Thanks! 

Link to comment
  • 0

Your Summary Block is showing some upcoming events, so the message will not be shown.

1943208354_Screenshot2020-04-30at12_19_46.png.7f6cd6e8bd3a37ca0277f2cd25592369.png

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment
  • 0
On 4/30/2020 at 1:21 PM, paul2009 said:

Your Summary Block is showing some upcoming events, so the message will not be shown.

1943208354_Screenshot2020-04-30at12_19_46.png.7f6cd6e8bd3a37ca0277f2cd25592369.png

Sorry for the late reply. There are two Summary Blocks on the page - one is located under the headline 'Events' and not showing anything (this is the one, where I would like the 'no upcoming events' text), while the other is showing the latest blogposts (the one in your screenshot). 

Maybe the problem is that there are two Summary Blocks on the page? 

  

Skærmbillede 2020-05-05 kl. 20.42.52.png

Link to comment
  • 0
22 minutes ago, Yasheng said:

It also doesn't work for my 7.1 site. 

@Yari @Yasheng

I provided this solution in 2018 when Squarespace 7.1 did not exist! 🤔

If you'd like assistance with a 7.1 site, please post a question that includes the URL of the page on your site and what you'd like to achieve. If the site is hidden from public view, please set a site password and tell us what it is.

 

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment

Create an account or sign in to comment

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

×
×
  • Create New...