Specifying a Template

October 16, 2005

How does one specify which template a page has? In Prototype 2 each page had a <template> tag to specify it’s template. An attractive alternative springs to mind based on the following disadvantages of the <template> tag.

  • We’re adding propietary tags (contrary to guiding principles)
  • XML Documents from 3rd party sources (docbook, word, rss, etc) would need this tag added

Particularly the second point is important if you consider importing 100’s of XML documents from an external system. Each one would need the <template> tag added. So, what’s the alternative? Folders!

Each folder has a corresponding template which is the default for documents in that folder. The pages in folder /content/pages/news/ would all have the template /design/templates/page/news.xsl applied by default. Of course the XML Author can specify another template using our trusty <template> tag.

Sounds great but: Folders introduce a new level of complexity in linking documents. With our old flat, single folder system linking was as simple as specifying the target pages name with the <a href="page.htm"> tag. As soon as you have folders you need to either:

  • mirror the folders structure in your published site: <a href="/news/page.htm"> OR
  • keep the flat site structure and rename published pages to (try and) ensure uniqueness of filename: <a href="news.page.htm">

Both options are equally complex (well, less simple) than the previous situation and the 1st option is more intuitive. We all like folders in our published site.

Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment