Ctrl + click behaviour on smarty tpl path

Hi,

 

I'm working on a project running with smarty. Tpl files are located in templates/ directory and I call them in my php with $smarty->display('dir/myTpl.tpl'); but I can't find a way to go to the tpl file directly with ctrl + click on it.

I tried adding the templates in PHP include path but it doesn't do the trick.

Any idea?

2 comments
Comment actions Permalink

Hi there,

Usually such navigation is provided by plugins (e.g. Laravel plugin does it for methods that are used to call Blade view files; Symfony plugin does similar stuff for Symfony/Twig files etc).

For Smarty templates, Smarty plugin does not provide this (it only offers syntax/completion stuff that is inside actual Smarty templates).

Few ideas:

  • Find a plugin that can interpret any sting and treat it as a file path. There was one which I have tried few years ago (Navigate From Literal), but it got broken/no longer maintained for quite long time now. See if File Path Autocomplete plugin will do any good (nah, it helps with completion but not navigation...).
  • Inject File Reference "language" into such string (so IDE treats it as file path -- must have at least 3 symbols in a string; place caret inside and invoke Quick Fix menu (Alt+Enter); choose appropriate option). This has be done manually for each place (special PHPDoc-like comment /** @lang XXX */ does not support FileReference -- see https://youtrack.jetbrains.com/issue/IDEA-139705).. but as you would imaging it's not practical (both manual or via comment). I personally do not know how to inject this for all $smarty->display() instances automatically, but check PHP Toolbox plugin -- it can do quite a lot of things and this might be possible there (my impression)
  • Just select the "dir/myTpl.tpl" bit and then hit Ctrl+Shift+N (or whatever you have got for "Navigate | File") -- it will search for that file as if you have typed it there -- better than nothing.
  • Write your own plugin that will associate FileReference with $smarty->template() calls...
0
Comment actions Permalink

There is a very similar request on our tracker already:

https://youtrack.jetbrains.com/issue/WI-2345

You may notice that it is quite old and somewhat abandoned but we have decided to re-open it after a discussion.

0

Please sign in to leave a comment.