cancel
Showing results for 
Search instead for 
Did you mean: 

Editing a Widget to Link to another Page

SOLVED

Editing a Widget to Link to another Page

Hi! 

 

We have a magento 2.4.3 store front and I'm trying to make a change to a widget.

 

We have what we call a benefits bar, and I would like to link the text "Orders before 3pm" to another page on the website, I've tried to do this using both HTML tags and the insert variable tag but every time it breaks the bar. Any suggestions on how to get a link on text using page builder? 

 

This is the bar:

Screenshot 2024-08-28 084339.png

 

This is the code:

Screenshot 2024-08-28 084418.png

 

Thanks in Advance. 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Editing a Widget to Link to another Page

Hello @kierandaym7fe9,

 

you're trying to add a hyperlink to the text "Orders Before 3pm" in the widget. This can be tricky in Magento's Page Builder, as it sometimes strips HTML when not used correctly. To ensure your link works without breaking the bar, follow this:

Try adding the link directly within the text. For example:

<p>{{widget type="Absolute\CustomWidgets\Block\Widget\PromotionalBannersWidget"

banner_one_title="Free Delivery on Orders Over £150"

banner_one_tagline="UK Mainland"

banner_two_title="Orders Before 3pm"

banner_two_tagline="<a href='/link-to-page'>Orders Before 3pm</a>"

banner_three_title="Price Match Guarantee"

banner_three_tagline="Lowest Prices"}}</p>

Make sure to replace /link-to-page with the actual URL path you want to link to.

If Page Builder is stripping HTML tags, try disabling WYSIWYG for that particular section while editing, and switch to raw HTML mode. This can often prevent Magento from removing valid tags.

 

If this approach doesn't work, it could be that your custom widget

 

Absolute\CustomWidgets\Block\Widget\PromotionalBannersWidget is sanitizing or not allowing HTML in its properties. If this is the case, you may need to adjust the widget code in your module by ensuring that the specific fields (banner_two_tagline, etc.) allow HTML input. For example, in your widget's block class, you might need to modify it to allow escapeHtml=false

This might be work.

 

If the issue will be resolved, Click Kudos & Accept as a Solution.

View solution in original post

3 REPLIES 3

Re: Editing a Widget to Link to another Page

 

Go to Content > Pages or Blocks, or Content > Widgets if it's in a widget, and find the benefits bar to edit. Highlight "Orders before 3pm" in the Page Builder editor, click the Link icon, insert the URL, and choose whether it opens in the same tab or a new one.

 

Avid learner and technical marketer at devrims.com

Re: Editing a Widget to Link to another Page

Hello,

 

Thank you for coming back to me. 

 

This isn't located in widgets and in the block only have the information from the screenshot. Do you have any other suggestions on how to do this? 

 

Thanks 

Re: Editing a Widget to Link to another Page

Hello @kierandaym7fe9,

 

you're trying to add a hyperlink to the text "Orders Before 3pm" in the widget. This can be tricky in Magento's Page Builder, as it sometimes strips HTML when not used correctly. To ensure your link works without breaking the bar, follow this:

Try adding the link directly within the text. For example:

<p>{{widget type="Absolute\CustomWidgets\Block\Widget\PromotionalBannersWidget"

banner_one_title="Free Delivery on Orders Over £150"

banner_one_tagline="UK Mainland"

banner_two_title="Orders Before 3pm"

banner_two_tagline="<a href='/link-to-page'>Orders Before 3pm</a>"

banner_three_title="Price Match Guarantee"

banner_three_tagline="Lowest Prices"}}</p>

Make sure to replace /link-to-page with the actual URL path you want to link to.

If Page Builder is stripping HTML tags, try disabling WYSIWYG for that particular section while editing, and switch to raw HTML mode. This can often prevent Magento from removing valid tags.

 

If this approach doesn't work, it could be that your custom widget

 

Absolute\CustomWidgets\Block\Widget\PromotionalBannersWidget is sanitizing or not allowing HTML in its properties. If this is the case, you may need to adjust the widget code in your module by ensuring that the specific fields (banner_two_tagline, etc.) allow HTML input. For example, in your widget's block class, you might need to modify it to allow escapeHtml=false

This might be work.

 

If the issue will be resolved, Click Kudos & Accept as a Solution.