How Can I Know the Current Page is Magento 2 CMS Page

How can I know the current page is CMS page from Magento 2 Block class

You can use “\Magento\Framework\App\Request\Http” to retrieve the current request and use it to find out which module.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $request = $objectManager->get(‘\Magento\Framework\App\Request\Http’); $checkModule = $request->getModuleName();
if($checkModule == ‘cms’){
echo “cms page”;
}else{
echo “not cms page”;
}
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments