Jump to content


Circle Member
  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by alicroft

  1. @Robilanyo Here's what my developer came up with, and it seems to be holding up. Note this was all done on 7.0. Live page with the below code: https://www.theveilbrewing.com/rva-sa #1 "Enable Ajax Loading" must be turned off for this to work. Located in: Design> Site Styles > Site: Loading #2 Code to be inserted into the Page header, located in: Page > Settings > Advanced > PAGE HEADER CODE INJECTION <script defer> window.Squarespace.onInitialize(Y, function(){ function addZero(i) { i = i < 10 ? "0" + i : i; return i; } function calcUpdatedTime(customDate) { const date2 = new Date(customDate); const displayDate = (date2.getMonth() + 1) + '/' + date2.getDate() + '/' + date2.getFullYear(); const displayPM = date2.getHours() > 11 ? 'PM' : 'AM'; const displayMinutes = addZero(date2.getMinutes()); let displayHours = date2.getHours() > 12 ? (date2.getHours() - 12) : date2.getHours(); if(date2.getHours() == 0) displayHours = 12; const displayTime = displayHours + ':' + displayMinutes + displayPM; return "UPDATED:<br />" + displayDate + "<br />@ " + displayTime; } function createUpdateLinkDiv() { updatedDiv = document.createElement('div'); updatedDiv.setAttribute("id", "updated-at"); updatedLink = document.createElement('a'); updatedLink.setAttribute("id", "updated-link"); updatedLink.setAttribute("href", "#rva-sa-update-note"); updatedDiv.append(updatedLink); document.body.appendChild(updatedDiv); } let myHeaders = new Headers(); myHeaders.append('pragma', 'no-cache'); myHeaders.append('cache-control', 'no-cache'); const myInit = { method: 'GET', headers: myHeaders, }; const url = window.location.href.replace(location.hash,"") + "/?format=json-pretty"; fetch(url, myInit) .then((resp) => resp.json()) .then(function(data) { let recentUpdate = 0; const collections = data.collection.collections; for ( var i = 0; i < collections.length; i++ ) { if(collections[i].urlId.indexOf('beer-list') > -1){ recentUpdate = collections[i].updatedOn; } } createUpdateLinkDiv(); document.getElementById("updated-link").innerHTML = calcUpdatedTime(recentUpdate); }) .catch(function(error) { // If there is any error you will catch it here }); }); </script> #3 You can style the box by targeting #updated-at in your css here: Design > Custom CSS Let me know if you have any questions, I will try to help!
  2. @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.
  3. Thank you so much @paul2009, that worked perfectly! For anyone else trying the same: The script did not work in the page header injection (/nfk-events), but it did in the Index Collection header injection (/nfk).
  4. 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)
  5. Thanks so much, @brandon! This is super helpful. I'm going to reach out to my more-experienced-than-me dev friend to see if he can assist in implementing, and if he can't, I'm going to hit you up!
  6. I have a sticky "Last Updated on /Date/ at /Time/" div that I've custom-coded to appear on particular pages of a client's website. Currently, the client needs to go in to the custom code and manually enter the Date and Time whenever they update the page's content. Is it possible to code this so the date and time automatically update whenever the client makes an edit to the page? There are multiple Indexes that will each need their own unique "updated at" box. It's important for the box to be sticky, visible no matter where you are on the page, because the content that gets updated is long; we want to ensure the user doesn't miss the "updated at" date and time. Page example w/ current sticky block: https://veil-test-1.squarespace.com/rva-sa pass: test2019 The code is currently located in the PAGE HEADER CODE INJECTION of the Index Settings, and styled with custom css. I'm open to changing the whole set up if I can make it so the client doesn't have to get into the code at all! Thanks in advance for any and all ideas!
  • 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.