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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.