It is possible to use folders within the folder “views” like:
I have tested but cannot get the wp-routing to work.
Thank for some help regarding my issue
Yes, You can use folders within the “views” folder.
For access such blades, you have to use
Hope this helps…
Sorry, but you misunderstood me.
I know that it is possible to include partials and other blade-files within any folder with @include.
But my question was to add folders within the folder “views” that should be understood by wordpress routing rules. I mean, a file named single-news.blade.php means that I want to see a aingle page from the posttype “news”.
If I put that file into a folder inside the folder “views” wordpress routing rules cannot find the file.
But maybe there is a way to do that with some Sage trick.
Thanks anyway for your answer
WordPress won’t find files that are in subfolders in this context, so what you’re describing won’t work. You could adapt the technique used in the basic sage theme in the
single.blade.php file, and just modify the partial it tries to load:
@include('single.single-' . get_post_type())
OK, so Sage has no function for this? My wish was to change somewhere that the wp resources could be loaded from “resources/views/#/” and not from “resources/views/”. But maybe that is not possible in any way. Hmmm… I have to find some another solution for this. Becuse my problem is not to @include in different ways. That will not solve my problem. My problem is to let Wordpress understand to find files in folders with the folder “views”.
Sage just uses the WP Core function
locate_template to find which blade files to load: https://github.com/roots/sage/blob/bd38502616188be973f60b75717eea95c1fc69d2/app/helpers.php#L120-L127 If you’d like to modify the behavior to do a deeper search, you could do that fairly easily by modifying Sage’s search logic.
This topic was automatically closed after 42 days. New replies are no longer allowed.