CMS Development

FloStu
Contributor | Gold Partner
Contributor | Gold Partner

Convert 'inline_text field' to URL Slug

SOLVE

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
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Convert 'inline_text field' to URL Slug

SOLVE

@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
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Convert 'inline_text field' to URL Slug

SOLVE

@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.

Rachel-Marvel
Contributor

Convert 'inline_text field' to URL Slug

SOLVE

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" %}

? 🙂

0 Upvotes
Rachel-Marvel
Contributor

Convert 'inline_text field' to URL Slug

SOLVE

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 😄

tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Convert 'inline_text field' to URL Slug

SOLVE

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

0 Upvotes
Rachel-Marvel
Contributor

Convert 'inline_text field' to URL Slug

SOLVE

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 🙂