How to show in which function I am, while visiting HTML code
Working on a huge PHP file, having a lot of
... ?>
many HTML lines
<?php ...
When in the middle of HTML Lines (after a search for instance), I'd like to see in what function I am, but PS shows at the bottom (which is nice by the way) the current DOM tree position
body > div.main > form > div > table > tr > td > ...
instead of the usual function name when in the PHP code.
Is there a way (or setting) to quickly see in what function I'm working?
Thanks
Please sign in to leave a comment.
Hi there,
Yes, if it's your own code / code that you can change. Simply do not mix and keep your PHP functions code separately to your HTML / page template. For example:
If you cannot do anything with that code / want to keep it mixed -- no real suggestions from me on this one, except put ALL of the PHP code at the top and HTML template down below.
Not my code, and I won't take the risk to change it that far.
Too bad that [Alt-Q]ⁿ gives the DOM tree context bottom to top, and stops at the DOM top (does not go up to the function name).
Thanks for the answer anyway.
Can you share some sample file (as a link to download, not the copy-paste text here)? I do not really have such code (have not had it for a really long time) so want to check something (how IDE behaves).
In my "PHP code at the top" mixed case it seems to work (basically: all code in 1 PHP function, then collect all script params and call the function, then the template):
What you may try here is the Structure toolwindow: if you use "PHP" tab and tell it to keep focus from the source, it should automatically select/focus the function there. Not ideal but better than nothing.
I won't upload the code I'm working on (privacy), but it is easy to reproduce.
Create a PHP file with a couple lines, and a function
And then visit https://www.jetbrains.com/ , do "View page source", and paste the source code, from '<HTML>' in place of '<=== HERE ===>'.
The goal is to see myFunction() (bottom bar) when the cursor is in the middle of the HTML code...
Just saw your new message, will have a look...
Thanks Andriy, I think the Structure window is great, and addresses the problem ; didn't use it much before (=almost never, thanks for the great tip).
You can also use "File Structure" popup (Navigate > File Structure) for this - it would highlight a PHP object your cursor currently in.
Indeed! Thanks Dmitry, that answers my initial question (doing Ctrl F12).
But actually the Structure Tool Window is ... just fantastic! Having all the time on the left side the position where the cursor is, plus much more info...
Must have tried that at the beginning and then forgot about it (didn't need it at the time).
Great to hear it!