Jump to content

Folder structure into Template Folder not working..


Junaid Farooqui
 Share

Recommended Posts

Hi Guys, 

I am trying to create a folder structure in templates folder because i going to have a huge list of templates so for future use i want to create a folder structure in template folder so returning user can easily find and modify them according to requirements.  e.g

i have few templates for pages and few templates which i am going to use in templates as includes files. i am calling them BLOCKS. so i want to create block folder into the template folder but in admin panel when i am adding new template it's not picking up block1.php file which is located in Templates>Blocks> ...

Is there any option so we can enforce PW to pick folders from inside a folder in templates folder.

Regards
J

 

 

 

Link to comment
Share on other sites

Hey man!

I do not know about a straight forward way to place template files in subfolders. I remember that I did struggle with it when I was new to the system. But know I do not think about it as a limitation. There are a lot of ways to organize the structure of your template folder, and none of them will limit you to include any kind of blocks from other folders.

Just look at this and you'll have it figured out. If not - feel free to ask for details.

Link to comment
Share on other sites

AFAIK the template files that connect to PW templates need to be in root, and that's a good thing;

you wouldn't want it looking in folders where you might have hundreds of other php files.

So your clean template folder will only have PW template files in root and all others in folders..

Link to comment
Share on other sites

Basicly this boils down to the fact that with processwire you dont make website the cms way but your way. And you are not going to find your way until after you have made a dozen websites with processwire. Everytime when I finished a website with processwire I saw a better way to organize things in the templates folder in combination with "everything is a page" in your admin folder tree. The delayed output way fits best with organizing things your own way in the templates folder. There are really many posts about this in the forum I cant recall of them now I recommend you look for them, but here is a good example to start with from Camilo Castro:

https://medium.com/@clsource/the-wire-render-pattern-806bf6d6097a#.rk8g785m9

 

  • Like 4
Link to comment
Share on other sites

Hi @Junaid Farooqui, welcome to the PW an the Forums.

I use a similar approach like you described. But I don't have to use templatefiles for all of my blocks. I only use a few main template files (mostly 2-5, and max around 10 for really large sites). For the blocks I use the Profield RepeaterMatrix, what is explained here:

https://processwire.com/blog/posts/more-repeaters-repeater-matrix-and-new-field-rendering/#repeater-matrix-is-released-alpha

https://processwire.com/api/modules/profields/repeater-matrix/

With repeater-matrix you are able to level down the block / field files to different extends. My prefered usage is one matrix field with different blocktypes but one rendering file under site/template/fields. But one also can use one separate rendering/view file per blocktype under site/templates/fields/...
Also it is possible to mix those usecases how you like.

Repeater-Matrix was alpha in January 2016, but is stable now. Do cost a bit money, but is more than worth the saved time. You are able to build nearly an exact usage scenario with the free available Pagetable Field and additional template files for each blocktype. But it is more work and feels not that smooth like Repeater Matrix.

Just another possibility here. :)

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...