Show Similar Posts in Graffiti
Date Published: 10 July 2008
I couldn’t find this with GoogleLive Search but ScottW hooked me up. If you want to show related or similar posts in your posts in Graffiti, just add this script to your post.view file (which, amazingly enough, you can do via the admin tool without FTPing any files to your blog – how cool is that?).
<span style="color: #008000">#set($similarPosts = $data.SimilarSearch($post.Id,3)) #foreach($sp in $similarPosts)</span>
<span style="color: #008000">#beforeall</span>
<h3>Similar Posts</h3>
<ol id=<span style="color: #006080">"similarPosts"</span> class=<span style="color: #006080">"list"</span>>
<span style="color: #008000">#each</span>
<li><a href=<span style="color: #006080">"$sp.Url"</span>>$sp.Title</a></li>
<span style="color: #008000">#afterall</span>
</ol>
<span style="color: #008000">#end</span>
In theory, at the bottom of this post, you now see a Similar Posts section… I’m not 100% sure what magic it uses to determine that a post is “similar” – we’ll just have to see.
Tags - Browse all tags
Category - Browse all categories
About Ardalis
Software Architect
Steve is an experienced software architect and trainer, focusing on code quality and Domain-Driven Design with .NET.