Question

For some reason, the little script we used to get the current year in the copyright block under Content/design/configuration/footer is not being executed. It is being treated as normal text in the frontend

Backoffice:

back-office

Frontend:

frontend

What could be the problem?

Was it helpful?

Solution

This is not a bug. It's a feature.

In the template html/footer.phtml from the Magento_Theme module there is this:

<address><?= $block->escapeHtml($block->getCopyright()) ?></address>

getCopyright returns exactly what you have in your config field.
This means that the value is escaped before printing it on the screen.
If you don't want this escape, you can override the template in your theme and replace the code above with

<address><?= $block->getCopyright(); ?></address>

But this will leave you exposed to XSS if someone inserts some (harmful) javascript code in your copyright section.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top