brettlair Posted September 10 Share Posted September 10 (edited) Hello! I know there's code to randomize your homepage gallery showing your portfolio work, but is it possible to randomize one single portfolio page's gallery when on that specific page? For example, in the link below, I'd like these images to be randomized each time the page is loaded. However, I don't want that to occur on other portfolio pages where I have things in a specific order. Is that even possible? https://www.brettlair.ca/work/logos Edited September 11 by brettlair Updated "portfolio" to "gallery" in the first sentence to be more accurate. Beyondspace 1 Link to comment
Beyondspace Posted September 11 Share Posted September 11 19 hours ago, brettlair said: Hello! I know there's code to randomize your homepage gallery showing your portfolio work, but is it possible to randomize one single portfolio page's gallery when on that specific page? For example, in the link below, I'd like these images to be randomized each time the page is loaded. However, I don't want that to occur on other portfolio pages where I have things in a specific order. Is that even possible? https://www.brettlair.ca/work/logos You can insert the code to a code block of the page, so it will affect that page only BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox - Lightbox captions only mode) 🗓️ Delivery Date Picker (Squarespace Date picker form field) 💫 Gallery block 7.1 workaround 🥳 No-code customisations for Squarespace 🚀 Learn how to rank new pages on Google in 48 hours! 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
brettlair Posted September 11 Author Share Posted September 11 Unfortunately I can't do that directly though because the page falls under the "Work" section in the nav which is a Portfolio layout. I can get it to randomize my homepage gallery no problem, but that's not what I want to do. Beyondspace 1 Link to comment
Beyondspace Posted September 23 Share Posted September 23 On 9/11/2024 at 9:37 PM, brettlair said: Unfortunately I can't do that directly though because the page falls under the "Work" section in the nav which is a Portfolio layout. I can get it to randomize my homepage gallery no problem, but that's not what I want to do. Okay, then you can identify the page ID, which is unique for every page, then it will only work for the specific porfolio page BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox - Lightbox captions only mode) 🗓️ Delivery Date Picker (Squarespace Date picker form field) 💫 Gallery block 7.1 workaround 🥳 No-code customisations for Squarespace 🚀 Learn how to rank new pages on Google in 48 hours! 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
brettlair Posted September 25 Author Share Posted September 25 This is the code that will randomize everything on my homepage. I'm not entirely sure how/where to add the specific page ID though. Quote <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> <script> document.addEventListener('DOMContentLoaded', function() { const productGrid = document.querySelector('div#gridThumbs'); if (productGrid) { var productItems = productGrid.querySelectorAll('.grid-item'); for (var i = productItems.length; i >= 0; i--) { productGrid.appendChild(productItems[Math.random() * i | 0]); } } }); </script> Link to comment
tuanphan Posted September 28 Share Posted September 28 On 9/25/2024 at 7:05 PM, brettlair said: This is the code that will randomize everything on my homepage. I'm not entirely sure how/where to add the specific page ID though. Suppose your Portfolio Page ID is: #collection-66a1bfc99041e47b896c1e48 Change your code to this <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> document.addEventListener('DOMContentLoaded', function() { const productGrid = document.querySelector('#collection-66a1bfc99041e47b896c1e48 div#gridThumbs'); if (productGrid) { var productItems = productGrid.querySelectorAll('.grid-item'); for (var i = productItems.length; i >= 0; i--) { productGrid.appendChild(productItems[Math.random() * i | 0]); } } }); </script> 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!) Link to comment
brettlair Posted September 30 Author Share Posted September 30 On 9/27/2024 at 11:17 PM, tuanphan said: Suppose your Portfolio Page ID is: #collection-66a1bfc99041e47b896c1e48 Change your code to this <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> document.addEventListener('DOMContentLoaded', function() { const productGrid = document.querySelector('#collection-66a1bfc99041e47b896c1e48 div#gridThumbs'); if (productGrid) { var productItems = productGrid.querySelectorAll('.grid-item'); for (var i = productItems.length; i >= 0; i--) { productGrid.appendChild(productItems[Math.random() * i | 0]); } } }); </script> I only have "item" and "section on this page instead of "collection". Wondering if that's because it's a "Portfolio" category page? 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