Jump to content
teppo

Template naming conventions

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

Share this post


Link to post
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

Share this post


Link to post
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 1

Share this post


Link to post
Share on other sites

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? 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Mithlesh
      Changing it to null
    • By Mithlesh
      Hi, I have one URL - writerrelocations.com/contact-now/

      I have one issue where my header Image is appearing again after the contact form, for your reference:



      I have checked my processwire template section where have not added any Image field besides Header Image, attaching the same for the reference:




      PLEASE help me to get rid of the image below contact form

      Waiting for the swift response!

      Thanks
       
    • By DooM
      Hello,
      I'm working on something like "structure generator" for my own needs which is run after clean installation of PW to create basic structure, fields, install modules, remove unnecessities, etc.
      I'm trying to remove site/templates/scripts and site/templates/styles folders, but I'm out of ideas already. When I try PHP's unlink function, it says that the path doesn't exists, which is obvious, because it will try to delete those folders under FileCompiler folder. This is probably because PW compilation process? I'm initializing this mine "structure generator" in ready.php.
      Do any of you guys have any idea how to get rid of those folders? My styles and scripts folders are separated, so I don't need those two inside templates folder.
      Thanks for every advice. 🙂
    • By Liam88
      Hi all,
      Quick question as I haven't found anything from my Googling. 
      I have a blog on the site which utilises pagination. On the standard blog page I have a custom header which has featured posts.
      Below that I then have recent posts like mosts blogs.
      Now if i click to page two or three I want the header to disappear and just show a continuation of the standard posts.
      I'm not sure how to go about this so any direction would be helpful.
      Thanks
    • By NorbertH
      As we are building some webapplications with the PW backend , having those really big spacings between all field elements in forms and everywhere is not too practical. 
      UI Kit already has less spacings between all elements than Bootstrap for example , but i am looking fore a more condensed BE Theme.  Maybe someone already made something like that?
×
×
  • Create New...