Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

global blocks? Have them and don't want them


Geekless
Go to solution Solved by brandon,

Question

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.

Screen Shot 2019-10-16 at 11.56.12 AM.png

Link to post
  • Answers 7
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

Popular Posts

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 reme

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 t

Also note that I've changed {collection.id} to {item.id} in my example, which is more likely what you're after.

Posted Images

7 answers to this question

Recommended Posts

  • 1

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

Edited by brandon

If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' vote.jpg.c260784ece77aec852b0e3049c77a607.jpg (top-left)

Link to post
  • 0

Yeah, that's right. I've updated my answer to clarify, and to make the distinction between collection id and item id more clear.

Edited by brandon

If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' vote.jpg.c260784ece77aec852b0e3049c77a607.jpg (top-left)

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...