37

Just started playing about with Magento 2.

Can anyone tell me where I can find the "Template Path Hints" option that used to be in System > Configuration > Developer > Debug?

1

10 Answers 10

57

You can only see some settings in developer mode. So first of all check that you are in developer mode, if not then run this command php bin/magento deploy:mode:set developer in root directory.

Then go to admin panel:

For Front End:

Store > Configuration > Advanced > Developer > Debug > Enabled Template Path Hints for Storefront > Yes


For Admin :

Store > Configuration > Advanced > Developer > Debug > Enabled
Template Path Hints for Admin > Yes

7
  • I have enabled but not able to see hints on either frontend or admin dashboard
    – siddhesh
    Jul 13, 2017 at 14:20
  • 2
    Note that this menu item is visible in developer mode only. php bin/magento deploy:mode:set developer Feb 24, 2018 at 10:11
  • @rakesh can you please help me on this? magento.stackexchange.com/questions/246502/… Oct 22, 2018 at 10:16
  • I have followed your post which you have provide for by default selection for options while loading the page prnt.sc/l8xn28 Oct 22, 2018 at 10:19
  • Not sure this is still true for 2.2.6, and will use n98 command line option.
    – camdixon
    Oct 24, 2018 at 4:33
24

You can do it by two ways:

  1. Using cli:

goto you project root directory on command line and run below command

php bin/magento dev:template-hints:enable 

php bin/magento dev:template-hints:disable 
  1. go to admin backend:

    Store > Configuration > Advanced > Developer > Debug > Enabled Template Path Hints for Storefront > Yes

    Stores > Configuration > Advanced > Developer > Debug > Enabled Template Path Hints for Admin > Yes

    Stores > Configuration > Advanced > Developer > Debug > Enabled Template Path Hints for Add Block Names to Hints > Yes

enter image description here

Hope, this will help some extend.

2
20

Go to admin

For Front End:

Stores > Configuration > Advanced > Developer > Debug > Enabled Template Path Hints for Storefront > Yes

For Admin :

Stores > Configuration > Advanced > Developer > Debug > Enabled Template Path Hints for Admin > Yes

11

If you use n98-magerun2 script from https://github.com/netz98/n98-magerun2

Run the following from website root to enable hints

n98-magerun2.phar dev:template-hints --on

And this to disable

n98-magerun2.phar dev:template-hints --off
2
  • 2
    enable / disable is not a valid argument to pass, therefore will not do as you have described. The function will toggle without that argument. The correct argument to pass is the store code. github.com/netz98/n98-magerun#template-hints
    – Tisch
    Feb 23, 2017 at 11:11
  • Technically it is correct, the store code default is added by... default. :) and in situations where admin is needed, admin is used. Majority of stores are usually running one store view/website. n98-magerun does a good job detecting your default view also: github.com/netz98/n98-magerun/blob/… If you're trying to only target a non-default store code, then yes the argument would be required, but without still technically NOT invalid.
    – B00MER
    Jun 13, 2017 at 1:02
8

If you are connected to database, you can enable by running below query,

For Frontend:

update core_config_data set value = 1 where path = 'dev/debug/template_hints_storefront'

For Admin:

update core_config_data set value = 1 where path = 'dev/debug/template_hints_admin'

Flush Cache

php bin/magento cache:flush OR 
php bin/magento cache:clean OR
From admin flush cache
3
  • this is not in magento2
    – Sushivam
    Mar 2, 2017 at 9:54
  • This will work for Magento 2 as well. please check SELECT * FROM core_config_data` WHERE path LIKE '%dev/debug%'` Mar 2, 2017 at 10:09
  • Magento <2.2 doesn't have dev:template-hints:[enable,disable], so this is what you need to use from CLI for that version..
    – jojman
    Jan 20, 2019 at 9:38
7

With command line we can also disable/enable path hint in Magento 2.2

For Enable

php bin/magento dev:template-hints:enable 

For Disable

php bin/magento dev:template-hints:disable
2

If you don't worry about using a free extension I'd suggest this one:

https://github.com/ho-nl/magento2-Ho_Templatehints

Ho_Templatehints extends the default Magento template hints.

  • Easily accessible with with muscle memory ?ath=1.
  • Shows hints for Templates, AbstractBlocks (Blocks), Containers and UI Components.
  • No layout interference: Using css outline instead of borders of other HTML elements, so it doesn't f'up the layout.

Not really an answer to the question, but hopefully useful if you work with template hints or want to debug layouts/templates.

1

Open vendor/magento/module-developer/Model/TemplateEngine/Plugin/DebugHints.php

write this code inside afterCreate function : (at the start, above the storecode line)

if(isset($_GET['shreyasPathHints']) && $_GET['shreyasPathHints'] == 'on'){
    return $this->debugHintsFactory->create([
        'subject' => $invocationResult,
        'showBlockHints' => 1,
    ]);
}

Now, you can open any Magento page and append ?shreyasPathHints=on to the URL. No need to run any commands.

P.S. I strongly discourage this method. Only to be used on the local system.

0

As Magento 1 provided, similarly Magento 2 providing with additional Option "Enabled Template Path Hints for Admin"

Go to admin ->

Store -> Configuration -> Advanced -> Developer -> Debug -> Enabled Template Path Hints for Storefront -> Yes

Store -> Configuration -> Advanced -> Developer -> Debug -> Enabled Template Path Hints for Admin -> Yes

1
  • 2
    Other answers already covered this way
    – 7ochem
    Dec 19, 2017 at 11:14
0

Several of these answers demonstrate use of parameter

This feature has been built into 2.3 for a little while now

Store > configuration > advanced > developer

https://github.com/magento/magento2/blob/7aa94564d85e408baea01abc5315a0441401c375/app/code/Magento/Backend/etc/adminhtml/system.xml#L126-L133

                <field id="template_hints_parameter_value" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
                    <label>Parameter Value</label>
                    <depends>
                        <field id="*/*/template_hints_storefront">1</field>
                        <field id="*/*/template_hints_storefront_show_with_parameter">1</field>
                    </depends>
                    <comment>Add the following parameter to the URL to show template hints ?templatehints=[parameter_value]</comment>
                </field>

Your Answer

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

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