3

I created custom category attribute like full description and just copy layout and template from category description. But all text i put in my custom full description display with html tags full description display with html tags

in admin page

1 Answer 1

1

Try following code:

Block file of your custom module:

<?php

namespace [VendoreName]\[ModuleName]\Block\Content;

use Magento\Store\Model\StoreManagerInterface;

class Content extends \Magento\Framework\View\Element\Template
{
    protected $_scopeConfig;

    protected $_filterProvider;

    protected $_storeManager;

    public function __construct(
        \Magento\Cms\Model\Template\FilterProvider $filterProvider,
        \Magento\Backend\Block\Template\Context $context,
        array $data = []
    ) {
        $this->_scopeConfig = $context->getScopeConfig();
        $this->_storeManager = $context->getStoreManager();
        $this->_filterProvider = $filterProvider;
        parent::__construct($context, $data);
    }

    public function getCmsFilterContent($value='')
    {
        $html = $this->_filterProvider->getPageFilter()->filter($value);
        return $html;
    }
}

Template file of your custom module:

<div>
    <?php $content = 'Content to be filtered' ?>
    <?php $html = $block->getCmsFilterContent($content);  ?>
    <p>
        <?php echo $html ?>
    </p>
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.