Skip to content

How to display modal popup when event is triggered

I already try this :

public function execute(Observer $observer)
{
     $layout = '<referenceContainer name="main">
        <block class="CMBlockModalOverlay"
               template="C_M::modal_overlay.phtml"/>
    </referenceContainer>';
    $observer->getLayout()->getUpdate()->addUpdate($layout);
    $observer->generateXml();
}