Burchard Posted May 6, 2023 Posted May 6, 2023 For the 'additional info' below a product, I would like to use a code block that loads pre-formatted text from a file on my web server (either uploaded through the Squarespace interface or via FTP, whichever works best). I want to do this so that I can change the additional information for all products on the website at once, by changing only one document, instead of manually going through all products one by one. It would save a lot of time,and minimize the chance of errors. The website is built on 7.0 in the Brine family. How can such a thing be achieved? Thanks for your input. Beyondspace 1
Beyondspace Posted May 6, 2023 Posted May 6, 2023 7 hours ago, Burchard said: For the 'additional info' below a product, I would like to use a code block that loads pre-formatted text from a file on my web server (either uploaded through the Squarespace interface or via FTP, whichever works best). I want to do this so that I can change the additional information for all products on the website at once, by changing only one document, instead of manually going through all products one by one. It would save a lot of time,and minimize the chance of errors. The website is built on 7.0 in the Brine family. How can such a thing be achieved? Thanks for your input. I suggest you place the content into a external page and load the page content into your product page using AJAX request BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </> 🗓️ Delivery Date Picker (Date picker form field) Gallery block 7.1 workaround </> 🤖 Ask me anything
Burchard Posted May 6, 2023 Author Posted May 6, 2023 1 hour ago, Beyondspace said: I suggest you place the content into a external page and load the page content into your product page using AJAX request Thanks for your reply! Can you explain how to do this? I'm not familiar with using AJAX requests.
Burchard Posted June 5, 2023 Author Posted June 5, 2023 Giving this a bump. I would really like to achieve this, but do not have any experience using AJAX requests. It would be great if someone can give me directions. Thanks!
creedon Posted June 5, 2023 Posted June 5, 2023 (edited) Quote loads pre-formatted text Can you tell us more about this formatted text? Is it text that can be input into a text block and maintain the formatting you want? AJAX is one way to go. Another way that is commonly used is to put a block in the site footer, hide, then use code to move it into place. Which method you use may be driven by the complexity of the formatted text you mention. Edited June 5, 2023 by creedon 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.
Burchard Posted June 6, 2023 Author Posted June 6, 2023 11 hours ago, creedon said: Can you tell us more about this formatted text? Is it text that can be input into a text block and maintain the formatting you want? AJAX is one way to go. Another way that is commonly used is to put a block in the site footer, hide, then use code to move it into place. Which method you use may be driven by the complexity of the formatted text you mention. It will be two text blocks, divided with a line block, with some bold text and one or two hyperlinks. I think the solution with the hidden block in the footer might be a good way to achieve this. How would you go about this?
creedon Posted June 7, 2023 Posted June 7, 2023 15 hours ago, Burchard said: How would you go about this? A basic overview. Create a text block in the footer with your text. Hide that text block with CSS. Note the block id of the text block. Create a code block in the product Additional Info that contains the following. <x-placeholder></x-placeholder> Use the following code to replace the code block in additional info. The settings in the code would look something like the following. This is an example. '#block-64797599d9caa1491329a76c' : { selectorDestination : 'x-placeholder', // selectorParentDestination is optional selectorParentDestination : '.sqs-block-code', action : 'replace' // values are append, prepend or replace }, This is not a solution as we would need to see some of these elements in action on a site to provide a solution. Another note. If you end up needing to moving a group of objects together as a design, this idea may not be appropriate. 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.
Burchard Posted June 7, 2023 Author Posted June 7, 2023 13 hours ago, creedon said: '#block-64797599d9caa1491329a76c' : { selectorDestination : 'x-placeholder', // selectorParentDestination is optional selectorParentDestination : '.sqs-block-code', action : 'replace' // values are append, prepend or replace }, Thank you for your solution. I've made the adjustments, but I'm not sure where I should add this bit of code?
creedon Posted June 7, 2023 Posted June 7, 2023 3 hours ago, Burchard said: but I'm not sure where I should add this bit of code? Find the similar looking lines in the Elements Manipulate code and change them. 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.
Burchard Posted June 8, 2023 Author Posted June 8, 2023 I've done that, but no success yet. I'm working on this page to achieve the desired effect: https://www.maartenrots.nl/la-aldea-azul-editions/untitled-juzcar-2023-1/ Maybe you can spot where I am failing? Thanks again, your help is much appreciated
Solution creedon Posted June 8, 2023 Solution Posted June 8, 2023 Quote Maybe you can spot where I am failing? In part the failure is mine. I had a syntax error in my code. Replace the following in the code... /* '[enter selector source here between single quotes replacing square brackets]' : { selectorDestination : '[enter selector destination here between single quotes replacing square brackets]', /* selectorParentDestination is optional, use when you want to first find a selector destination but then work up the ancestor hierarchy to manipulate it */ selectorParentDestination : '.sqs-block-code', action : 'replace' // values are append or replace }, */ '#block-yui_3_17_2_1_1686202370694_2971' : { selectorDestination : 'x-placeholder', /* selectorParentDestination is optional, use when you want to first find a selector destination but then work up the ancestor hierarchy to manipulate it */ selectorParentDestination : '.sqs-block-code', action : 'replace' // values are append, prepend or replace }, ...with the following code. /* '[enter selector source here between single quotes replacing square brackets]' : { selectorDestination : '[enter selector destination here between single quotes replacing square brackets]', // selectorParentDestination is optional, use when you want to first // find a selector destination but then work up the ancestor hierarchy // to manipulate it selectorParentDestination : '[enter selector parent destination here between single quotes replacing square brackets]', action : 'append' // values are append or replace }, */ '#block-yui_3_17_2_1_1686202370694_2971' : { selectorDestination : 'x-placeholder', // selectorParentDestination is optional, use when you want to first // find a selector destination but then work up the ancestor hierarchy // to manipulate it selectorParentDestination : '.sqs-block-code', action : 'replace' // values are append, prepend or replace }, Replace your footer hiding CSS with the following. html:not( .squarespace-damask ) .Footer #block-yui_3_17_2_1_1686202370694_2971 { display : none; } Let us know how it goes. Burchard 1 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.
Burchard Posted June 9, 2023 Author Posted June 9, 2023 (edited) That worked like a charm, thanks a lot! I imagine this will be helpful for others as well, thank you for your generosity in sharing your skills and the code, much appreciated! Edited June 9, 2023 by Burchard grammar creedon 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment