Jump to content


Photo

Template naming conventions

template templates convention

  • Please log in to reply
2 replies to this topic

#1 teppo

teppo

    Sr. Member

  • Members
  • PipPipPipPip
  • 413 posts
  • 416

  • LocationFinland

Posted 24 May 2012 - 12:18 PM

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.)

#2 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,586 posts
  • 906

  • LocationVihti, Finland

Posted 24 May 2012 - 12:45 PM

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.

#3 DaveP

DaveP

    Sr. Member

  • Members
  • PipPipPipPip
  • 302 posts
  • 156

  • LocationChorley, UK

Posted 24 May 2012 - 12:48 PM

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!
Twitter : Facebook : GitHub : G+ : Blog : Powered by C8H10N4O2 and C10H14N2





Also tagged with one or more of these keywords: template, templates, convention

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users