0

I want to override the magento\framework\view\page\config.php file setMetadata($name, $content) method to remove the htmlentites in meta description when we are viewing the page source code.

For that i did following code

di.xml file:

    <preference for="vendor\magento\framework\View\Page\Config" type="Logo\Importer\Framework\View\Page\Config" />

Logo\Importer\Framework\View\Page\Config.php file:

<?php
namespace Logo\Importer\Framework\View\Page;

class Config extends \Magento\Framework\View\Page\Config
{
    public function setMetadata($name, $content)
    {
        $this->build();
        $this->metadata[$name] = htmlspecialchars($content);
    }
    
}

But its still not removing the htmlentities from page source code.

Any help can be appreciated.

Thanks!

1 Answer 1

0

You can try the below possible solution which removes the HTML tags from the content.

Solution 1 : Magento way

echo $content_data = $this->escapeHtml($content);

Solution 2 : PHP way

$content = '<h1>welldone test</h1>';
echo strip_tags($content);

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.