How to Get WYSIWYG Editor’s data in Magento 2 Frontend Programmatically

To get the WYSIWYG editor's data on the frontend in Magento 2

Create registration.php

Directory

app\code\VendorName\ModuleName\registration.php

Content of registration.php

<?php
        \Magento\Framework\Component\ComponentRegistrar::register(
            \Magento\Framework\Component\ComponentRegistrar::MODULE,
           'VendorName_ModuleName',
            __DIR__
        );

Create module.xml

Directory

app\code\VendorName\ModuleName\etc\module.xml

Content of module.xml

<?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="VendorName_ModuleName" setup_version="1.0.0"/>
    </config>

Create ConfigBlock.php

app\code\VendorName\ModuleName\Helper\ConfigBlock.php

Content of ConfigBlock.php

<?php
   namespace VendorName\ModuleName\Helper;
    use Magento\Framework\App\Helper\AbstractHelper;
    
    class ConfigBlock extends AbstractHelper
    {
        protected $templateProcessor;
        public function __construct(
            Context $context,
            \Zend_Filter_Interface $templateProcessor
        )
        {
            $this->templateProcessor = $templateProcessor;
            parent::__construct($context);
        }
        public function getConfigContent($content) // $content you need to pass config value
        {
            try{
                return $this->templateProcessor($content);
            }catch (\Exception $e){
                return false;
            }
        }
    }
We are providing the best Magento 2 Extensions in the UK for International Magento Clients at low price. If you are looking for Magento Developers, visit Magento Development Agency.
Related Products