How can I easily control the look and feel of my site?

While non-ColdFusion techniques like an effective CSS file are one way to easily control layout across a site, you also want to consider using custom tags, and custom tag "wrappers" as a way to maintain a consistent look and feel across your site. Custom tags "wrappers" are simply custom tags that wrap content. As an example:

Stuff here

When ColdFusion runs this file, it will execute the custom tag, foo, twice. Once before "Stuff here" and once after. You can programatically determine if foo is being run in the beginning or end of execution. This is done using the builtin thisTag scope and the executionMode value.

<cfif thisTag.executionMode is "start">
Code here to run in the beginning.
Code here to run at the end.

This technique then is very useful for handling layout. You can easily use a layout custom tag that handles outputting a header and footer using the code above. Then wrap your pages with code like so:

This is my page!

This entry was based on a suggestion by Mat Evans.

This question was written by Raymond Camden
It was last updated on July 3, 2008.


Display and Layout


comments powered by Disqus