Custom Interaction New data() short code 🤯

Blocs for Mac 6.1 introduces a brand new feature to custom interactions that is going to be a real game changer and massively change the way you create interactions, it will allow you to do more with less! :sunglasses:

You can now use the short code data() within your custom interactions to retrieve custom attribute data from the trigger element.

How it Works
Let me explain how this all works. :nerd_face:

I have a button that I am using to trigger a custom interaction.

I have a data attribute added to this button (data-target-page) that contains a link to another page.

Within the Custom Interaction that this button is connected to, I use the new data() short code to get this attribute and feed it into a navigate to URL rule.

The benefit of this is, I can now use a single interaction on multiple buttons rather than create a separate interaction to link to each page. All I have to do is change the custom data attribute on the trigger element (in this case a button) and this will effect how the interaction works.

You can feed these data() values into into any of the text fields with your Custom Interaction Rules and you can use any type of string data to pass into the interaction. So you could feed in an elements ID string or a colour hex code string, whatever you want really.

Currently data() will only work on elements that trigger interactions, it will not work on the page load or scroll trigger.

4 Likes

Nice added feature, Norm! :smiley:
Where do we get a list of the short code that could be used with Interaction?

There is no list you can use any type of attribute e.g data(get-myspecial-data) or data(blocs-rocks). You just need to make sure the trigger element has the data attribute applied.

The page transition experiment uses this new method.

2 Likes

Sounds like a fantastic addition, @Norm.

I can already envision a few cool use cases for this feature. However, I would greatly appreciate it if you could share a few examples where the data() short code proves particularly useful. Thanks a bunch!

3 Likes

Hey @Eldar I have just posted a new example using the data() short code feature to dynamically populate the content of a modal.

2 Likes

Thanks, Norm! :pray:

1 Like

I have a blocs page with a dozen carousels. They all have within the carousel links that to lead a page.

Can I use the Custom Interaction New data() short code so a user can click on the image and or video anywhere within the carousel and have it leads to another page? Each carousel would leads to its own page.

Yeah you can do that.

Here is a Sample Project for you to take a look at.

1 Like

Thank you so much, Norm :smiley:

2 Likes

No problemo :raising_hands:

I tried what you did @Norm, see attached capture, and I cannot get this to work on other carousels on the page. What am I doing wrong?

Apparently, even though I make a new interaction, there are somehow tied together.

That is not correct, you have put two links in the same interaction. You only use one interaction exactly how my sample project works, apply the same interaction to each carousel. But (this is the important part) you update the custom data attributes on each carousel to point to the page.

You don’t do that in the interaction.

Hey Norm,
I’m still in learning mode when it comes to the interaction manager.
Thank you for hanging in there with me when I look at custom attributes I see that you have a web link in yours. For me I have 20 carousels that need weblinks. What is the easiest way to get those links if I need them?
I truly hope there is an easier way to do this then go and get all the links and then put them in the custom attribute area.

“I’m still in learning mode when it comes to the interaction manager”

that’s a step ahead of me @KBConcepts , I know it exists, look at it, get confused, and then get scared! Well done.

1 Like

Custom Attributes can be copy and pasted, so set one up to a page, test it works. Then copy and past the actual custom attribute item in the inspector and paste it on your next carousel that is using the interaction.

When you move to the new carousel first click into the empty space of the custom attribute controls before you paste.

CleanShot 2026-06-10 at 09.27.05

Once you have done that, you will need to manually, assign each page link, but because the rest is already set up its just a case of changing the page name in the value of each attribute.

Test after each carousel setup.

As for getting a list of all the page names you need, Im not sure about that.

Also I’m not sure you are aware but you can give the images in the carousels links as well, this is done entirely with the inspector and the classic interactions.

Thank you Norm for your reply.

I’m not sure how you know how much work this will be, so it would be a great idea just to have a drop down to choose the pages like you do and the Interaction (/pages.htm) “pages”.

I clearly don’t have an understanding of this because I have tried this simple solution so many but I can’t get it to work.

I think because you want each carousel (x20) to point to a unique page (x20), it’s always going to be a little more time consuming regardless of your approach.

You select the images inside the carousel and then assign the page links to each image.

I actually just found a bug here, when you wrap a carousel image in a link it pushes the caption out of the carousel. But that will be fixed in 6.4.6 which will be released next week.

1 Like

That’s so exciting to me that you found the same bug that I was just about to report.
Thank you so much Norm

1 Like