I need to add a specific layout handle for all the pages when a certain value is present in the session.
To make it more clear, if $session->getMyValue()
returns true
I need to load a specific layout handle called my_specific_layout_handle
on every page I visit.
In the code above $session
is an instance of any subclass of Magento\Framework\Session\SessionManager
(not really relevant).
Is there any event I can use or any method I can pluginize?
Note: I'm not concerned with full page cache for now. Let's say it does not exist.
Best Answer
For Adding Layout Handles You Can Use Event Also:
In Your events.xml
In Your LayoutLoadBefore.php