Closed billmn closed 11 years ago
I'm not sure either. ;)
It will solve your particular use case, but it's a hack as it solves only that. Any other location will still fail.
To solve this properly you need a way to (dynamically) tell twig what your search paths are.
I think that is a problem for every dev that use Twig templates in a subfolder (in modules) ... is not a my particular case :)
"Any other location will still fail. " Why? I've only added the module views path ... anything else
"To solve this properly you need a way to (dynamically) tell twig what your search paths are." Mmmm what do you mean? This add the search paths to Twig ... no?
foreach ($this->active_request->get_paths() as $path) { array_unshift($views_paths, $path.'views'); }
Thank you man for the support! :)
That's my point.
Your views (the one you extend) are there, and therefor this solves your problem. Another user might have another standard folder layout in which their base views are elsewhere, and for them this is not a solution.
Paste IRC converstation :
[17:22] <billmn> "which their base views are elsewhere, and for them this is not a solution" [17:23] <billmn> ... mmm but this will still work as before right? [17:23] <WanWizard|busy> yes, as in "it will still not work for them" [17:29] <billmn> mmm ... for consistency ... what do you think about using the same syntax for normal views? like \View::forge('othermodule::subdir/view'); [17:29] <billmn> this method add the main path of the module to search paths? [17:45] <WanWizard|busy> it's the twig 'extend' that I'm talking about. if you use twig's own logic to access files, you will have to tell twig where to find them. [17:46] <WanWizard|busy> your fix does that, but hardcoded for the location that works for you. [17:47] <WanWizard|busy> for other people using different locations, that is not a solution. to fix this you need a way for me to set my "twig search paths", and you set yours, so that it works for both of us
Looking back at this, shouldn't this solve it (I'm not a twig user):
{% extends '../base.twig' %}
I'm not sure if this is the best method to fix the problem.
I will try to explain the problem using an example :
Suggestions?