How can I get the current page layout programatically?
I have tried this:
$block->getLayout()->getUpdate()->getPageLayout();
But the output is: 1column
but that is wrong.
Any idea how to get it?
How can I get the current page layout programatically?
I have tried this:
$block->getLayout()->getUpdate()->getPageLayout();
But the output is: 1column
but that is wrong.
Any idea how to get it?
Add this code in your file where you want to get.
protected $request;
public function __construct(
............................................
\Magento\Framework\App\Request\Http $request,
............................................
){
............................................
$this->request = $request;
............................................
}
Now you can add this code in your custom function or execute() function
$controller = $this->request->getControllerName();
$action = $this->request->getActionName();
$route = $this->request->getRouteName();
echo $controller."<br/>";
echo $action."<br/>";
echo $route."<br/>";
I Hope This Helps You.