Jump to content

Template naming conventions


teppo
 Share

Recommended Posts

It's common sense to name things based on meaning -- search, sitemap, home, basic-page / default etc. -- but I'm interested in hearing if you folks are defining / following more specific rules than these. This is something I've been thinking quite a bit lately and unfortunately I feel a bit lost here.

IMHO this becomes an important thing especially when you have multiple developers working on / providing support for same projects, which they aren't necessary familiar with. It's one of those things that make it easier for a new developer to jump on board of a project and instantly understand what's happening under the hood (or at least make educated guesses.)

So after this (longish) explanation, I'd really love to hear what you think about this subject -- what kind of naming conventions do you apply for your templates and/or fields? (If any.)

  • Like 2
Link to comment
Share on other sites

Well.. after template specific field settings the need for new fields have been much less and it is easier to use more generic field names. My usual projects do have all or some of these for example:

image

images

file

files

summary

body

date

datetime

tags (page field)

I also have some common template names used in many projects:

basic-page

home

members-home

events

event

news

news-item

I try to use what is given on demo template. Also, trying to keep all the field and template names In English. Nothing too special here, interested to hear about others.

  • Like 3
Link to comment
Share on other sites

It's common sense to name things based on meaning

Absolutely right. I tend to try for 'self-documenting' code, in other words (exactly as you say), naming things based on meaning. This is for templates, fields and other variables.

What I also do is use includes in templates for common page elements (which I am sure everyone does) and name them meaningfully. Also grouping template files by purpose is useful. For example, I'll name my includes inc.head.php, inc.foot.php etc, so they are grouped together in any list or file selector.

While I was writing, I see apeisa got in before me! I also try to keep things in English, but even for a native English speaker sometimes you wouldn't think I was!

  • Like 2
Link to comment
Share on other sites

  • 6 years later...

It's an old post but still a hot topic…

I create a lot of websites for clients in german, sometimes in french. I often end up with a mix of languages either in the fields or templates names… Anybody working with multilanguage sites with a good practice suggestion? 

Link to comment
Share on other sites

17 hours ago, lenoir said:

It's an old post but still a hot topic…

I create a lot of websites for clients in german, sometimes in french. I often end up with a mix of languages either in the fields or templates names… Anybody working with multilanguage sites with a good practice suggestion? 

I usually use english names for the templates and fields (german websites). I think everybody understands that ?

  • Like 1
  • Thanks 1
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...