Jump to content

global blocks? Have them and don't want them

Recommended Posts

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 comment
  • Replies 7
  • Views 1.4k
  • Created
  • Last Reply

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' vote.jpg.c260784ece77aec852b0e3049c77a607.jpg (top-left)

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.