Naming Conventions for XSLT

20 May 2009 by Administrator

Naming Conventions - XSLT filenames and Macros

We prefix all our macros and xslt files with a word which describes the function of the code. This encourages developers to reuse existing code, improves organisation in the backend and speeds up templating and workflow.

  • - Get
  • - Merge
  • - List
  • - Ext
  • - Nav
  • - Library
  • - Meta


(get)
- $currentPage data specific. E.g get Header, get Body, get Image.

(merge) - $currentPage/nodes specific, display childen at any depth, used for content mash ups.

(list) - Similar to merge, but should only be used for list data.

(ext) - Used to output code to other applications, e.g Flash, RSS Feeds, XML (sitemaps), etc

(nav) - Used for any navigation code.

(library) - References a set of code used by other code.

(meta) - Code used to display meta elements.

Any suggestions, or ideas are welcome! :) but this document will make the macro's in future blog posts make more sense.

Examples...

  • (ext)GoogleSiteMap
  • (nav)Level1-FrontPage
  • (list)NewsItems

5 comment(s) for “Naming Conventions for XSLT”

  1. Gravatar of Sander Houttekier
    Sander Houttekier Says:
    this made me think seriously about the topic. It is indeed 1 way to catalog your xslt's and find them the next time.

    to me it depends on what site i'm working. we have a big project with lots of subsites, we tend to keep all macro's / templates / xslt/s / specific doc types prefixed with an identifier that shows which subsite it belongs to.

    but the 2 options are not possible together, which made me think, if more people are interested, we could suggest something like tagging on xslt / templates / ...
    then i can tag it with (nav) or (ext) AND an identifier for subsite.
    the tagging would not be such a big issue, though i guess the big work would be to use those tags afterwards, a textbox or sort of select list to filter your tags
    ... in order to quickly find your xslt / ...

    though does the few times we need such a thing justify the work needed to get it done, i'm not sure
  2. Gravatar of Doogie Talons
    Doogie Talons Says:
    Great ideas, but I am new to umbraco. My question is, without inline XSLT how you make a call such as value-of select="data [@alias = 'seoDescription']

    recursive ?
  3. Gravatar of Laurence
    Laurence Says:
    Hi Doogie,

    Thanks for commenting...

    The easiest way to do this, would be to create a new XSLT file and macro, and then add a line of code like...

    <xsl:value-of select="$currentPage/data [@alias = 'seoDescription']" disable-output-escaping="yes"/>

    You could then wrap this in a xsl:choose with a test, so when the seoDescription was empty it defaulted to something else...
  4. Gravatar of Doogie Talons
    Doogie Talons Says:
    Cheers, I thought it would be something like that but hoping there was something simple like the inline command. I agree with the principle though and will stop being lazy.
  5. Gravatar of DyelsTedylile
    DyelsTedylile Says:
    Yes, really.

Leave comment:

Name:  
Email:  
Website:
Comment: