sabercosmos Posted November 14, 2022 Posted November 14, 2022 Hey folks. I just found out how to use code to hide particular sections from view in mobile, and this has been super helpful. What I'd like to do next might be a bit more complicated though... Can I use code to remove sections from a specific URL too? For example, with my Shop I'd like to make it so I have a categories section displayed for the storefront, but i'd like to remove them from the specific category pages (eg. my Charms, Prints sub-sections). Is there a way to do this? I would usually do a code injection into the header, but since it's the shop it technically doesn't have seperate pages... I've drawn up what i'm looking for incase that was confusing! I have the Squarespace IDs extension downloaded btw if that helps. Many thanks!
Beyondspace Posted November 14, 2022 Posted November 14, 2022 2 hours ago, sabercosmos said: Hey folks. I just found out how to use code to hide particular sections from view in mobile, and this has been super helpful. What I'd like to do next might be a bit more complicated though... Can I use code to remove sections from a specific URL too? For example, with my Shop I'd like to make it so I have a categories section displayed for the storefront, but i'd like to remove them from the specific category pages (eg. my Charms, Prints sub-sections). Is there a way to do this? I would usually do a code injection into the header, but since it's the shop it technically doesn't have seperate pages... I've drawn up what i'm looking for incase that was confusing! I have the Squarespace IDs extension downloaded btw if that helps. Many thanks! You can combine using media query Css and target the right section id you want to hide @media only screen and (max-width: 767px) { section-id { display: none; } } The extension to get right section id: Squarespace ID Finder How to get section id: https://recordit.co/Aj9vXw6rfY 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
Beyondspace Posted November 14, 2022 Posted November 14, 2022 If you still do not figure out, you can share your site with the protected password so we can take a look 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
sabercosmos Posted November 14, 2022 Author Posted November 14, 2022 1 hour ago, Beyondspace said: You can combine using media query Css and target the right section id you want to hide Thanks! This works, but it hides the section from all the shop sections. Is there a way to reveal it only for one category? Also sorry my original post was a bit unclear- I'd like to do this for both desktop and mobile. 🙂 Website: https://www.sabercosmos.co.uk/ Pass: forum The section i'd like to have the "Shop by Collection" section in is Shop > All, and i'd like to remove it from the rest (like Shop > Prints and etc)
tuanphan Posted November 21, 2022 Posted November 21, 2022 On 11/14/2022 at 11:11 PM, sabercosmos said: Thanks! This works, but it hides the section from all the shop sections. Is there a way to reveal it only for one category? Also sorry my original post was a bit unclear- I'd like to do this for both desktop and mobile. 🙂 Website: https://www.sabercosmos.co.uk/ Pass: forum The section i'd like to have the "Shop by Collection" section in is Shop > All, and i'd like to remove it from the rest (like Shop > Prints and etc) Do you still need help on this? Last week I helped a similar case for a member Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
sabercosmos Posted November 24, 2022 Author Posted November 24, 2022 On 11/21/2022 at 8:34 AM, tuanphan said: Do you still need help on this? Last week I helped a similar case for a member Yes please! Would you mind linking me the post? 🙂
tuanphan Posted November 30, 2023 Posted November 30, 2023 On 11/28/2023 at 8:38 PM, ianeaf said: Hi @tuanphan, may you please share the post link? Also looking for this. Thanks! You can share link to page + Which section you want to hide, we can check easier I don't remember the code I used, need to check it on new site Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
cami_leisk Posted March 13 Posted March 13 I'm trying to do exactly this and wondering if anyone could help me? URL: https://www.vitriccaiannazzi.com/shop-real PW: vitricca I have added a section that has images that correspond + link with the main categories in the shop. They look great on desktop but they take up all the vertical space on mobile. What I would like to do is hide them on every category except the ALL category. I've been trying several different things including hiding the section completely on mobile, but there is a padding issue that I can't seem to fix that causes the shop section to bleed up into the header. This is the page that I would like to keep the first section visible on mobile https://www.vitriccaiannazzi.com/shop-real For every other category I would like to hide the first section on mobile.
tuanphan Posted March 15 Posted March 15 On 3/13/2024 at 9:27 PM, cami_leisk said: I'm trying to do exactly this and wondering if anyone could help me? URL: https://www.vitriccaiannazzi.com/shop-real PW: vitricca I have added a section that has images that correspond + link with the main categories in the shop. They look great on desktop but they take up all the vertical space on mobile. What I would like to do is hide them on every category except the ALL category. I've been trying several different things including hiding the section completely on mobile, but there is a padding issue that I can't seem to fix that causes the shop section to bleed up into the header. This is the page that I would like to keep the first section visible on mobile https://www.vitriccaiannazzi.com/shop-real For every other category I would like to hide the first section on mobile. Try this code to Website > Website Tools > Code Injection > Footer <script> if (document.location.pathname.indexOf("/shop-real/wabi-sabi") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/shop-real/retro") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/shop-real/style") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/shop-real/tropical") == 0) { document.querySelector('body').classList.add('t-hide') } </script> <style> body.t-hide [data-section-id="65bae2de7e897252a2037ce4"] { display: none; } body.t-hide [data-section-id="6524479cc6a84c06b4ee2fc6"] { margin-top: 150px; } </style> cami_leisk 1 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
E-W Posted March 29 Posted March 29 On 3/15/2024 at 4:22 AM, tuanphan said: Try this code to Website > Website Tools > Code Injection > Footer <script> if (document.location.pathname.indexOf("/shop-real/wabi-sabi") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/shop-real/retro") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/shop-real/style") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/shop-real/tropical") == 0) { document.querySelector('body').classList.add('t-hide') } </script> <style> body.t-hide [data-section-id="65bae2de7e897252a2037ce4"] { display: none; } body.t-hide [data-section-id="6524479cc6a84c06b4ee2fc6"] { margin-top: 150px; } </style> @tuanphan I'm trying to use this code to hide the first 'featured' section on this blog for specific category URLs but it isn't working. What am I doing wrong? <script> if (document.location.pathname.indexOf("/blog?offset=") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/blog/category/Engagement") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/blog/category/Elopement") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/blog/category/Newborn") == 0) { document.querySelector('body').classList.add('t-hide') } </script> <style> body.t-hide [data-section-id="6606cb21ffd5013539385ab2"] { display: none!important; } </style> website: https://helicon-oval-8wh9.squarespace.com/blog PW: admin
tuanphan Posted March 31 Posted March 31 On 3/29/2024 at 10:00 PM, E-W said: @tuanphan I'm trying to use this code to hide the first 'featured' section on this blog for specific category URLs but it isn't working. What am I doing wrong? <script> if (document.location.pathname.indexOf("/blog?offset=") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/blog/category/Engagement") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/blog/category/Elopement") == 0) { document.querySelector('body').classList.add('t-hide') } if (document.location.pathname.indexOf("/blog/category/Newborn") == 0) { document.querySelector('body').classList.add('t-hide') } </script> <style> body.t-hide [data-section-id="6606cb21ffd5013539385ab2"] { display: none!important; } </style> website: https://helicon-oval-8wh9.squarespace.com/blog PW: admin I don't see the code. Have you added it yet? I tried test code for Engagement from my browsers and it still works Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
E-W Posted April 1 Posted April 1 22 hours ago, tuanphan said: I don't see the code. Have you added it yet? I tried test code for Engagement from my browsers and it still works @tuanphan It works I just had the code in the wrong place. Thank you! tuanphan 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment