Jump to content

How do you organize template files?


Jaguar

Recommended Posts

Here's my site structure (very simplified)...

 

index.php
blog/
    index.php
    post.php
forum/
    index.php
    post.php

 

Now I want to create a basic template system, but I'm not sure how to store my template files. I can think of a couple ways.

 

One template directory with all the files. The drawback is I might have to get clever with naming the files or the the file names could get long.

 

templates/
    header.tpl
    footer.tpl
    index.tpl
    blog_index.tpl
    blog_post.tpl
    forum_index.tpl
    forum_post.tpl

 

Or a template directory in every directory. The drawback is I will have to include files from multiple directories.

 

templates/
    header.tpl
    footer.tpl
    index.tpl
blog/
    templates/
        index.tpl
        post.tpl
forum/
    templates/
        index.tpl
        post.tpl

 

Or multiple directories inside a single template folder.

 


templates/
    header.tpl
    footer.tpl
    index.tpl
    blog/
        index.tpl
        post.tpl

    forum/
        index.tpl
        post.tpl

 

I'm guessing this last solution is the right way, but  I like the simplicity of the first method (one directory).

Link to comment
https://forums.phpfreaks.com/topic/178514-how-do-you-organize-template-files/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.