AshwinG Posted July 8, 2023 Share Posted July 8, 2023 Hi, not sure if this is even possible. But I would like to have a button (or a hyperlinked word in a text block) which will link the user to a random page from a pre-selected list of pages on my site. The button is the one on the home page named 'Sunrise me!' (or the words 'Surprise me!' in the text block) and I would like it to randomly select one of my folio projects. /architecture/bower-studio /architecture/bonbeach-trail /graphic-design/commbank /photography/landscape etc... Just a fun little thing I want to add, but if it's not possible or too complicated, not a a big deal. Thanks Kind regards, Ashwin https://ashwingunawardana.squarespace.com/ Password: password Link to comment
creedon Posted July 8, 2023 Share Posted July 8, 2023 Please see the following. Let us know how it goes. AshwinG and KimmyBartle 2 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. Link to comment
AshwinG Posted July 9, 2023 Author Share Posted July 9, 2023 I was unable to get it to work. I put the code onto the home page settings > advanced > page header code injection. For "const selector" I put the block id of the button For "const urlPrefix' I tried '/' and '/collection_name' And for "const strings" I tried both 'collection-name/page-name' and '/page-name' I'm guessing I'm putting in the wrong values for one or more of these things. I want the list to have pages from different collections. So /architecture/bower-studio and /graphic-design/commbank and so on Link to comment
creedon Posted July 9, 2023 Share Posted July 9, 2023 Is the code installed now? 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. Link to comment
AshwinG Posted July 10, 2023 Author Share Posted July 10, 2023 I removed it because I wanted to publish the site. I've added it to a new page which is locked. https://ashwin.works/test-page password: mango Link to comment
Solution creedon Posted July 10, 2023 Solution Share Posted July 10, 2023 Quote I've added it to a new page which is locked. The selector needs to be... const selector = '#block-yui_3_17_2_1_1688984615330_1727 a'; This targets the block and the link in the block so the URL can be replaced. tuanphan and AshwinG 2 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. Link to comment
AshwinG Posted July 11, 2023 Author Share Posted July 11, 2023 Awesome, it works. Thank you so much creedon 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment