Convert 'inline_text field' to URL Slug

SOLVE
Highlighted
Occasional Contributor | Gold Partner

Hi,

 

it is possible to convert a 'inline_text'-field to a SEO url slug within the widget module?

I want to create anchor links from a text.

 

<div id="{% inline_text field="anchor_pillar_page" value="{{ module.anchor_pillar_page }}" %}">

text = Lorem ipsum Dolor?

slug= lorem-ipsum-dolor

 

Thanks

Flo

1 Accepted solution

Accepted Solutions
Highlighted
Solution
Top Advisor | Platinum Partner

@FloStu - I think you want to do something like this, text will be easier to work with than inline_text, if you add the export_to_template_context attribute:

{% text "anchor_text" value="add pillar name here" export_to_template_context="true" %}
<div id="{{widget_data.anchor_text.value|lower|replace(' ','-')}}">

If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

View solution in original post

5 Replies 5
Highlighted
Solution
Top Advisor | Platinum Partner

@FloStu - I think you want to do something like this, text will be easier to work with than inline_text, if you add the export_to_template_context attribute:

{% text "anchor_text" value="add pillar name here" export_to_template_context="true" %}
<div id="{{widget_data.anchor_text.value|lower|replace(' ','-')}}">

If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

View solution in original post

Highlighted
Regular Contributor

Hey Tim, 

Thanks a lot for your help. Can I just confirm that I should:
1) create a text field in the module 

2) inside the <a/> tag add the 

id={{widget_data.anchor_text.value|lower|replace(' ','-')}}" 

3)  and wrap it in the 

{% text "anchor_text" value="add pillar name here" export_to_template_context="true" %}

? 🙂

Reply
0 Upvotes
Highlighted
Regular Contributor

Finally got thsi to work - Thanks Tim for setting me on the right path. 

I created a text field in my component. added the 

{% text "anchor_text" value="add pillar name here" export_to_template_context="true" %}

just above my anchor tag. Then inside the anchor tag, I referenced the text field which contains my url eg 

 <a href="{{ module.link_url }}"/>

 That's it 😄

Highlighted
Top Advisor | Platinum Partner

@Rachel-Marvel - awesome, I did comment on your original question if you haven't seen the answer there.

Reply
0 Upvotes
Highlighted
Regular Contributor

yeah it was great - the only change I needed to make was to use module.name.value rather than widget_date.name.value - this may help others too 🙂