- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2020
01:45 AM
06-04-2020
01:45 AM
Magento 2 - widget cms get html parameters
I am using a wysiwyg field in my widget, value are well inserted but on frontend html markers and attributes are displayed as text.
{widget type="Vendor\Module\Block\Widget\Sliderimage" textarea="<ul> <li>Base </li> </ul>"}}
I have to first decode html special chars to reencode it in order to display html, this is heartbreaking.
Now i am do this:
$allowedTags = ['a', 'b', 'p', 'li', 'ul']; $textarea_1 = $block->escapeHtml(htmlspecialchars_decode($block->getData('textarea_1')), $allowedTags);
I use that widget block:
use Magento\Framework\View\Element\Template; use Magento\Widget\Block\BlockInterface; class Sliderimage extends Template implements BlockInterface
How can i hook beyond the getData functions to get my html parameter display in the right way ?
Thank you,
Damien.
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2020
02:03 AM
06-04-2020
02:03 AM
Re: Magento 2 - widget cms get html parameters
Hello @KennedyA
you can pass
{{block test=test"}}
in block file yo will get value by
$this->getData('test')
if works then mark as solution
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2020
02:21 AM
06-04-2020
02:21 AM
Re: Magento 2 - widget cms get html parameters
The widget is inserted in a content cms page for exeample, the html fied use the wysiwyg to use html code:
{widget type="Vendor\Module\Block\Widget\Sliderimage" textarea="<ul> <li>Base </li> </ul>"}}
We cannot use your solution.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2020
02:54 AM
06-04-2020
02:54 AM
Re: Magento 2 - widget cms get html parameters
Hello @KennedyA
what do you mean?
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020
03:06 AM
06-18-2020
03:06 AM
Re: Magento 2 - widget cms get html parameters
Your solution is not appropriate.