Is it possible to use folders with the folder "views"?

Hi everyone.

It is possible to use folders within the folder “views” like:

– layouts
---- app.blade.php
– partials
---- section-title.blade.php
---- author.blade.php
---- …
– page
---- page.blade.php
– template
---- template-section-page.blade.php
---- template-section.blade.php
– archive
---- archive-news.blade.php
---- archive-book.blade.php
– single
---- single-news.blade.php
---- single-book.blade.php

I have tested but cannot get the wp-routing to work.
Thank for some help regarding my issue :slight_smile:

Best Regards

Yes, You can use folders within the “views” folder.
For access such blades, you have to use
For SAGE9,
» @include(‘single.single-news’)
» \App\template(‘single.single-news’)

For SAGE10,

Hope this helps…:+1:

Hi PrecisionCoder13
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 :slight_smile:

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”.
Thanks anyway :slight_smile:

Sage just uses the WP Core function locate_template to find which blade files to load: 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.