Geekless Posted October 16, 2019 Share Posted October 16, 2019 Hey all, I’m using the Carson template and I’ve added a squarespace:block-field to the gallery.list code but when I add content to that block in the editor, the content gets added to every page that’s a gallery. Changing the block contents changes it on every gallery page. Anyone know why this is happening? My goal is to have an extra editable block in the gallery pages but have the contents of that block be specific to the page it’s on. Essentially make the block non-global. Link to comment
brandon Posted October 16, 2019 Share Posted October 16, 2019 Hi @Geekless. This occurs because the "id" attribute, as you have it, is static, and isn't unique to each page. It's that 'id' attribute to which a block field's layout is connected. To remedy this, add some JSON-T value that is appropriately unique. For collections/pages, that's the collection ID. But for posts/items within a collection, it's the item ID (because the collection is the same for all items within it). For example: <squarespace:block-field id="residential-{collection.id}" columns="12"/> Note: One thing you should watch for is what "scope" you are in when adding the block field within the .list code. In the example above, I've used {collection.id}. But, if in the context of your .list file, you are already within the {.section collection}...{.end} scope, you would only use {id} instead of {collection.id} in the example above. Including said values in the block-field id gives the block-field its "uniqueness" on a per-page/post level. What's the difference between collection id and item id? The collection id is unique to each collection. The item id is unique to each item within a collection (each blog post, or image, etc.). It's a matter of context as to which you want to use. In your case, because you're editing a .list file and you want to create multiple galleries where each list page has a set of block-fields unique to it, you'll use the collection id. Collections don't have an item id, so item id wouldn't work. If you wanted to have a block-field that was unique to each item in a gallery, you'd edit the .item file and use the item ID (because every item in a single collection would share the same collection id). Do let me know how that works for you. -Brandon If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' (top-left) Link to comment
Geekless Posted October 16, 2019 Author Share Posted October 16, 2019 so the collection ID is dynamically generated which then gives the string its uniqueness? Link to comment
brandon Posted October 16, 2019 Share Posted October 16, 2019 Yeah, that's right. I've updated my answer to clarify, and to make the distinction between collection id and item id more clear. If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' (top-left) Link to comment
brandon Posted October 16, 2019 Share Posted October 16, 2019 Also note that I've changed {collection.id} to {item.id} in my example, which is more likely what you're after. If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' (top-left) Link to comment
Geekless Posted October 16, 2019 Author Share Posted October 16, 2019 What's difference between the two? I've tried using the collection Id and it seems to be working just fine. Link to comment
brandon Posted October 16, 2019 Share Posted October 16, 2019 Hi @Geekless. I've updated my answer yet again. It seems my previous edit was a bit misleading. You do indeed want to use the collection ID for your use case. If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' (top-left) Link to comment
Geekless Posted October 16, 2019 Author Share Posted October 16, 2019 That makes sense! Thank you, Brandon! Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.