We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

If you are trying to print WYSIWYG editor content into the reading format in the code condition when content is added from the WYSIWYG editor from the admin panel, and content displays something weird, then you can solve the issue by following below steps.

Step 1: Create Registration

Create registration.php file in the app/code/Magemonkeys/Wysiwygdata folder with the following code.

<?php
MagentoFrameworkComponentComponentRegistrar::register(
    MagentoFrameworkComponentComponentRegistrar::MODULE,
    'Magemonkeys_Wysiwygdata',
    __DIR__
);

 

Step 2: Create a module

Create a module.xml file in the app/code/Magemonkeys/Wysiwygdata/etc folder with the following code.

<?xml version="1.0"?> 
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Magemonkeys_Wysiwygdata" setup_version="1.0.0"></module>
</config>

 

Step 3: Create a Helper

Create a Data.php file in the app/code/Magemonkeys/Wysiwygdata/Helper with the following code.

Add a dependency Zend_Filter_Interface to your block

<?php
    namespace MagemonkeysWysiwygdataHelper;
 
    use MagentoFrameworkAppHelperAbstractHelper;
    
    class Data extends AbstractHelper
    {
        protected $templateProcessor;
        public function __construct(
            Context $context,
            Zend_Filter_Interface $templateProcessor
        )
        {
            $this->templateProcessor = $templateProcessor;
            parent::__construct($context);
        }
        public function getWysiwygContent($content)
        {
            try{
                return $this->templateProcessor($content);
            }catch (Exception $e){
                return false;
            }
        }
 
    }

 

Now when you need to retrive data, you will just need to load helper and use getWysiwygContent() function by passing content

For Example,

Load helper “MagemonkeysWysiwygdataHelperData” using $_helper object

after loading helper you can access

$_helper->getWysiwygContent($content);

Fill the below form if you need any Magento relate help/advise/consulting.

With Only Agency that provides a 24/7 emergency support.

    Recent Articles
    Get a Free Quote