I have My block

 <block class="Vendor\ModuleName\Block\Frontend\Linked" name="catalog.product.linked" template="Vendor_ModuleName::slide.phtml" />

in this file


all i need to do is i want catalog_product_view name in my slide.phtml file

  • What's the purpose of that? Cause I don't think you can get that info in a phtml file, inside application flow May 9, 2019 at 8:15
  • i am placing my same block in two diffrent xml layout files... after that i just wanna check from which layout block is call
    – Waqar Ali
    May 9, 2019 at 8:16
  • did you check this magento.stackexchange.com/questions/228021/…
    – fmsthird
    May 9, 2019 at 8:19
  • i have tried this earlier what i got is 1column
    – Waqar Ali
    May 9, 2019 at 8:23
  • I guess that you want to try to get the handle file name from where slide.phtml?
    – Amit Bera
    May 9, 2019 at 8:46

2 Answers 2


Try this from phtml

$full_action_name = $this->getRequest()->getFullActionName();

It will return catalog_product_view, most of the time full action name is equal to layout name.

Example: module-catalog/etc/frontend/routes.xml

<route id="catalog" frontName="catalog">
   <module name="Magento_Catalog" />

The layout area path can be frontend or adminhtml which define where the layout will be applied.There is a special layout file name default.xml which will be applied for all the page in it’s area. Otherwhile, the layout file will have name as format:


You may use other solution - input type of block (or place where block is used) by <action method="setLinkType">...</action>

Advantages of this solution are the name of the block name.

You can put in your layout configuration (app\code\Vendor\ModuleName\view\layout\catalog_product_view.xml):

<block class="Vendor\ModuleName\Block\Frontend\Linked" name="catalog.product.linked" template="Vendor_ModuleName::slide.phtml">
    <action method="setLinkType">
        <argument name="link_type" xsi:type="string">place_one</argument>

Than you will get link type with $this->getLinkType() (in Vendor\ModuleName\Block\Frontend\Linked class) or $block->getLinkType() (in slide.phtml file)

For example:

if ($block->getLinkType() == 'place_two') {
    $do = 'something';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.