15/08/2022
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
To get the WYSIWYG editor's data on the frontend in Magento 2
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__
);
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>
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;
}
}
}