4

I know that you can turn template path hints on in Magento2 through the Admin Panel at Stores > Configuration > ADVANCED > Developer.

Although in Magento 1 I find it much quicker to temporarily edit a single line of code in app/code/core/Mage/Core/Block/Template.php. At line 200 I simply change:

return self::$_showTemplateHints; 

to

return true; 

It saves a lot of time than going through the admin panel. Is there somewhere in Magento 2 where I can similarly turn on Template Path hints by editing a line of code this way?

6 Answers 6

2

I strongly discourage this. Use at your own risk. Only to be used on local system.

Open vendor/magento/module-developer/Model/TemplateEngine/Plugin/DebugHints.php (tested in 2.3.2)

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.

1

I like ho-nl/magento2-Ho_Templatehints, you can get the required info without breaking the layout

ho-nl/magento2-Ho_Templatehints

0

My suggestion: use MageRun 2: https://github.com/netz98/n98-magerun2

Then you can just do:

n98-magerun2.phar dev:template-hints enable 

And to disable:

n98-magerun2.phar dev:template-hints disable 

But to answer your question, even if I strongly discourage that, just edit app/code/Magento/Developer/Model/TemplateEngine/Plugin/DebugHints.php and replace in the constructor:

$this->debugHintsPath = $debugHintsPath; 

With:

$this->debugHintsPath = true; 
1
  • thanks but editing vendor/magento/module-developer/Model/TemplateEngine/Plugin/DebugHints.php did not work for me. Commented Mar 17, 2017 at 12:23
0

It's saved in DB.

In table core_config_data, there are those 3 lines:

ID | default | 0 | dev/debug/template_hints_storefront | 1/0 ID | default | 0 | dev/debug/template_hints_admin | 1/0 ID | default | 0 | dev/debug/template_hints_blocks | 1/0 

In value column it's bool 1 or 0. You can write quick and dirty script to change that. Also there is plenty of tools that can help you with that.

If you use PhpStorm I would recomend http://www.magicento.com/ plugin.

0

I would like to recommend Easy Template Path Hints. It enables template path hints in magento 2 by just appending ?tp=1 in url and you can also add access code from admin configuration if you are thinking someone else would enable it.

It is very handy for frontend development.

2
0

You shouldn't edit code because at the end you will forget to remove it. Although I don't find template-hints useful anyway. It's strange such things don't exist in the command-line already but well.. You should add a new cli command to turn template-path hints on and off.

See: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/cli-cmds/cli-howto.html

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.