Set button options at template level

I am creating a template that uses buttons that jump down to the form, the form section has an anchor id of “contact”

How can I set the button settings at template level to set the button options to “Use as link” then the button link to be contact?

The below is my current button module settings

{% dnd_module
path=“../modules/button”,
button_text=“Add button text”
%}

Hi, @InciteJoe, thanks for the question! One question for context, are you getting an error when trying your current approach? I am hoping we can help give the community more details to work with.

Hey, @BarryGrennan, do you have any tips you can share with @InciteJoe?

Best,

Jaycee

Thanks @Jaycee_Lewis, @BarryGrennan managed to help me

That’s great to know, @InciteJoe! Thank you, @BarryGrennan :raising_hands:

Thanks for the tag @Jaycee_Lewis!

Hi @InciteJoe, assuming your button module is from the boilerplate you’d do it like this:

 {% dnd_module
path="../modules/button",
button_text="Add button text",link={"url":{"href":"#contact"}}
 %} 

Barry Grennan

Freelance HubSpot CMS Developer

Website | Contact | LinkedIn

Hi @BarryGrennan

Sorry I just tried it using this

{% dnd_module
path=“../modules/button”,
button_text=“Add button text1”,
link={“url”:{“href”:“contact”}}
%}

But the output I get from that is this

<button class=“button” id=“button_dnd_area-module-32” rel=“”>Add button text1</button>

@InciteJoe it looks to me like that button module isn’t from the boilerplate (at least the version I’m using) as the boilerplate outputs an anchor tag with a hs-button class rather than a button tag as yours does.

Can you post the content of the html area in your button module? It’ll give me a clue to what the url field is called


Barry Grennan

Freelance HubSpot CMS Developer

Website | Contact | LinkedIn

Sorry about that @BarryGrennan I am using the free Hubspot “Session theme” and I didn’t realise that it has a modified button module

It looks like it has a field group called “button_options” then a field within this called with a field called “button_link_toggle” with is a Boolean and then it just has the field called “button_link” which is a link field

Just had a look at Session theme.

I think what you’ll want to do is something like this:

{% dnd_module
path="../modules/button",
button_text="Add button text1",
button_options={"button_link_toggle": true},
button_link={"url":{"href":"#contact"}}
%}

Barry Grennan

Freelance HubSpot CMS Developer

Website | Contact | LinkedIn

Thanks @BarryGrennan that works perfectly!