How to change “Back to all events” and/or “View Event” text - Squarespace 7.1

Want to override and change the events text? Add the following custom code to your site.


Watch the video on YouTube


To change this on all “Events” used, add this to your Code Injection - Footer

To change this on a single “Events” section, go to “Events > Settings > Advanced > Page Header Code Injection”

<!--Back to Events and "View Events" text overrides -->

<script>
(function (document) {

  var eventButtonText = {}; // DO NOT DELETE

  // Back button text.
  var eventBackButtonText = 'Back'

  // Default text for all buttons for each event listing item.
  eventButtonText['default'] = 'View event →';

  // Target specific item in the event listing. Remove the 2 forward slashes
  // below before the `eventButtonText` variableto uncomment the lines. Update
  // the number in the bracket to equal the position of the event in the listing.
  // eventButtonText[1] = 'Event 1';
  // eventButtonText[3] = 'Event 3';

  /**************************************************************************
   * DO NOT EDIT CODE BELOW, unless you know what your doing.
   ***************************************************************************/

  // Initialized code depending on if the user places it in the header or footer
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', init);
  } else {
    init();
  }

  function init() {
    addNodeListForEachPolyfill();

    var eventButtons = document.querySelectorAll('.eventlist .eventlist-button');
    var backLink = document.querySelector('.eventitem-backlink');
    var text;

    if (eventButtons) {
      eventButtons.forEach(function (button, index) {
        index = index + 1;
        text = eventButtonText[index] || eventButtonText['default'];
        if (text) {
          button.textContent = text;
        }
      });
    }

    if (backLink) {
      backLink.textContent = eventBackButtonText;
    }

  }

  function addNodeListForEachPolyfill() {
    if (window.NodeList && !NodeList.prototype.forEach) {
      NodeList.prototype.forEach = Array.prototype.forEach;
    }
  }

})(document);
</script>

Will this work for embedded videos?

Currently this solution is only in place for videos uploaded directly to the Squarespace platform.

Previous
Previous

How to add a custom background colour to one section only - Squarespace 7.1

Next
Next

How to add a vertical video - Squarespace 7.1