There will be several ways to do this, I am sharing here 2 methods which I am aware of
- Replace the content in the server itself
- Replace the content in the client
Method 1:
You can do this either by after plugin or by using observer here I am proving an ex using observer
Create a events.xml file to subscribe cms_page_render event. This event will be triggered after the cms content is generated.
<event name="cms_page_render">
<observer name="your_module_cms" instance="Your\Module\Observer\AffectCmsPageRender" />
</event>
Create the Observer Model where you can modify the content as per your need
class AffectCmsPageRender implements ObserverInterface
{
public function execute(EventObserver $observer)
{
$page = $observer->getPage();
$content = $page->getContent();
/**
* Modify Content as per your need
*/
$page->setContent($content);
return $this;
}
}
Method 2:
Use JavaScript to modify the content before its visible to the user using require js 'domReady!'