3

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?

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;
  • thanks but editing vendor/magento/module-developer/Model/TemplateEngine/Plugin/DebugHints.php did not work for me. – Holly Mar 17 '17 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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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