GraffitiCMS View Override Examples
Thursday, January 28 2010 - graffiti
Graffiti uses a file with the extension .view to render the content of any given post or page. There is also a file called Layout.view, which controls the look a feel of the site. It is somewhat equivalent to an ASP.NET Master page. The default blog type setup has a Layout.view, Index.view, and Post.view.
The index.view basically has some if…then logic to determine how it should render:
#if($where == "tag")
<h1 class="archive_head">Entries tagged '$tag'</h1>
#elseif($where == "search")
<h1 class="archive_head">Search Results for '$macros.SearchQuery'</h1>
#end
What if you want a specific view for each category? Well then you have to create your view with the correct name.
Say I created the following Categories:
Info –> Stuff
Info –> More
So if I want the url: site/Info/ to render a specific view I need to create a view file named: Info.view.
What happens if I want to have a specific page for site/Info/Stuff/? Well then I need a file named: Info.Stuff.View.
This is where things get a little screwy. If I post an entry under the Stuff category, what file will render it? Essentially, if we want a customized look for those posts we need a file named: Info.Stuff.Post.View.
More examples soon.



