What is block.shopify_attributes used for in website sections?

Solved

What is block.shopify_attributes used for in website sections?

TheThisThat
Shopify Partner
64 3 17

What does this do and when should I be using it in my sections? Is it just whenever I call a block in my html? I've read the doc and still don't understand what it exactly does and when and why it is needed.

 

a little of this and a little of that
Accepted Solutions (2)

LitExtension
Shopify Partner
4958 1009 1190

This is an accepted solution.

Hi @TheThisThat ,

It helps to display block in file section. Refer https://help.shopify.com/en/manual/online-store/themes/os20/theme-structure/sections/#customize-your... 
You can refer to this code, it will show blocks when declaring schema, ex: https://github.com/Shopify/dawn/blob/main/sections/collection-list.liquid 
https://i.imgur.com/sYe3MD5.png 
Hope it clear to you.

If my answer can help you solve your issue, please mark it as a solution. Thank you and good luck.

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com

View solution in original post

james_tm
Shopify Partner
4 1 7

This is an accepted solution.

Hey @TheThisThat,

 

The accepted solution here didn't really seem to clear things up, so I did a little digging myself.


This article states:

 

We'll also use the block.shopify_attributes to add data attributes to the element. The theme editor's JavaScript API uses a block's shopify_attributes to identify blocks and listen for events. 

View solution in original post

Replies 4 (4)

LitExtension
Shopify Partner
4958 1009 1190

This is an accepted solution.

Hi @TheThisThat ,

It helps to display block in file section. Refer https://help.shopify.com/en/manual/online-store/themes/os20/theme-structure/sections/#customize-your... 
You can refer to this code, it will show blocks when declaring schema, ex: https://github.com/Shopify/dawn/blob/main/sections/collection-list.liquid 
https://i.imgur.com/sYe3MD5.png 
Hope it clear to you.

If my answer can help you solve your issue, please mark it as a solution. Thank you and good luck.

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com

james_tm
Shopify Partner
4 1 7

This is an accepted solution.

Hey @TheThisThat,

 

The accepted solution here didn't really seem to clear things up, so I did a little digging myself.


This article states:

 

We'll also use the block.shopify_attributes to add data attributes to the element. The theme editor's JavaScript API uses a block's shopify_attributes to identify blocks and listen for events. 

aubreytayloracn
Shopify Partner
3 0 3

For anyone who lands here in 2023, the answer to this question is documented here: https://shopify.dev/docs/api/liquid/objects/block#block-shopify_attributes

 

crunchycactus
Shopify Partner
4 0 1

Although these answers are correct, Shopify docs don't really explain it well. Here is an image of the functionality it adds.

 

crunchycactus_0-1735660375101.png

 

Hovering blocks in your custom section with the {{block.shopify_attributes}} allows you to click, drag, and interact with the popup tool bar.