hellomw Posted January 4, 2022 Share Posted January 4, 2022 Site URL: https://www.no-frames.com/photo-test Hi, I am using the tagcoud filter block and would like to be able to indicate what tag has been clicked on/currently viewing. Is this possible? Link to comment
Beyondspace Posted January 4, 2022 Share Posted January 4, 2022 4 hours ago, hellomw said: Site URL: https://www.no-frames.com/photo-test Hi, I am using the tagcoud filter block and would like to be able to indicate what tag has been clicked on/currently viewing. Is this possible? Add this to code injection - Footer <script> (function() { const tagCloud = document.querySelector(".sqs-tagcloud"); if (tagCloud) { const currentPath = location.pathname; const selectTag = tagCloud.querySelector(`li a[href*='${currentPath}']`); if (selectTag) { selectTag.style.fontWeight = "bold"; } } })() </script> BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations) 🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates) If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
hellomw Posted January 4, 2022 Author Share Posted January 4, 2022 11 hours ago, bangank36 said: Add this to code injection - Footer <script> (function() { const tagCloud = document.querySelector(".sqs-tagcloud"); if (tagCloud) { const currentPath = location.pathname; const selectTag = tagCloud.querySelector(`li a[href*='${currentPath}']`); if (selectTag) { selectTag.style.fontWeight = "bold"; } } })() </script> Thanks for the reply @bangank36, I appreciate it! I changed the current state to be an underline. However, whether bold or underline, it's not quite working. It appears only if refreshing every time, on every page. Even on the main blog page where neither tag has been selected, one shows selected on refresh. Link to comment
tuanphan Posted January 5, 2022 Share Posted January 5, 2022 @hellomw Try Design > Site Styles > Disable Ajax Loading Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
hellomw Posted January 6, 2022 Author Share Posted January 6, 2022 Thanks @tuanphan, that worked! Link to comment
Esin Posted September 30, 2022 Share Posted September 30, 2022 @tuanphan @bangank36 Is there a solution that would work under Design > Custom CSS? I am trying to do the same thing - when someone clicks a category at the top (all, motion graphics, or editing), the selected/currently viewing category should stay the hover color. Here is the custom CSS I already applied to the categories, if it makes a difference. Here is my website, pass: pqrs. Thank you! //tag cloud .sqs-tagcloud li a { color: rgb(67, 45, 199); background-color: #00000; font-style: regular; padding: 5px 10px; border-radius: 4px; font-size: 18px; -webkit-transition: .15s ease-out; -moz-transition: .15s ease-out; transition: .15s ease-out; } //tag cloud:hover .sqs-tagcloud li a:hover { background-color: rgba(173, 161, 242, .2); } Link to comment
Beyondspace Posted September 30, 2022 Share Posted September 30, 2022 This css code only sets the style when you hover the tag cloud. If you want to set the hover style for the active tag, we need to implement javascript to work around with it BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations) 🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates) If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
Esin Posted September 30, 2022 Share Posted September 30, 2022 I think that is a premium only feature, and I'm on the personal plan, so never mind! Thanks for responding. Link to comment
Diggles Posted December 3, 2022 Share Posted December 3, 2022 On 1/3/2022 at 10:06 PM, Beyondspace said: Add this to code injection - Footer <script> (function() { const tagCloud = document.querySelector(".sqs-tagcloud"); if (tagCloud) { const currentPath = location.pathname; const selectTag = tagCloud.querySelector(`li a[href*='${currentPath}']`); if (selectTag) { selectTag.style.fontWeight = "bold"; } } })() </script> Hello, Based on the turn off Ajax loading suggestion in the thread, I'm assuming this script is for 7.0. I'm using 7.1 and the first tag is always bolded, no matter which ?tag= has been clicked. Do you have any suggestions for how to make the script work in 7.1? My site is https://shop.digglesphotography.com Thank you for any help you can offer. Warren Link to comment
Diggles Posted December 5, 2022 Share Posted December 5, 2022 (edited) A programmer friend helped me by adjusting the above code to get it to work on my site. I'm assuming these adjustments are needed to get it working in SS 7.1. The code below will add an underline to the active tagcloud anchor tag <!--- Add style="text-decoration: underline;" for currently selected tag filter --------------------------> <script> (function() { const tagCloud = document.querySelector(".sqs-tagcloud"); if (tagCloud) { const currentPath = window.location.pathname + window.location.search; const selectTag = tagCloud.querySelector(`li a[href*='${currentPath}']`); if (selectTag) { selectTag.style.textDecoration = "underline"; } } })() </script> Instead of adding a style, I want to add a class. With my limited JS knowledge I was able to accomplish it by modifying the above script like this <!--- Add class="tag-active" for currently selected tag filter --------------------------> <script> (function() { const tagCloud = document.querySelector(".sqs-tagcloud"); if (tagCloud) { const currentPath = window.location.pathname + window.location.search; const selectTag = tagCloud.querySelector(`li a[href*='${currentPath}']`); if (selectTag) { selectTag.classList.add("tag-active"); } } })() </script> Edited December 5, 2022 by Diggles ktlr 1 Link to comment
ktlr Posted February 3 Share Posted February 3 On 12/5/2022 at 9:45 AM, Diggles said: A programmer friend helped me by adjusting the above code to get it to work on my site. I'm assuming these adjustments are needed to get it working in SS 7.1. The code below will add an underline to the active tagcloud anchor tag <!--- Add style="text-decoration: underline;" for currently selected tag filter --------------------------> <script> (function() { const tagCloud = document.querySelector(".sqs-tagcloud"); if (tagCloud) { const currentPath = window.location.pathname + window.location.search; const selectTag = tagCloud.querySelector(`li a[href*='${currentPath}']`); if (selectTag) { selectTag.style.textDecoration = "underline"; } } })() </script> Instead of adding a style, I want to add a class. With my limited JS knowledge I was able to accomplish it by modifying the above script like this <!--- Add class="tag-active" for currently selected tag filter --------------------------> <script> (function() { const tagCloud = document.querySelector(".sqs-tagcloud"); if (tagCloud) { const currentPath = window.location.pathname + window.location.search; const selectTag = tagCloud.querySelector(`li a[href*='${currentPath}']`); if (selectTag) { selectTag.classList.add("tag-active"); } } })() </script> Is this still the code you used for your site? It looks great! I'm trying to do something similar but the code isn't working. 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