(This will be the first in a series where I show how I solved some of
the issues in making http://osx.iusethis.com/)
Iusethis uses a common layout style with one main pane, and a smaller
right-hand sidebar. We've made it so it is easy to reuse these sidebar
items by putting them in a /sidebar folder in our template directory.
Then we can just do stuff like [% PROCESS sidebar/didyouknow.tt %],
and presto, you have a box like the one you can see on
SQLitemanager for
instance.
This box was implemented 100% in the TT view, so that it doesn't require
anything from the controller. To pick a random number, I use the TT Math
plugin like this:
[%USE Math %] [%SET tip=Math.int(Math.rand(10))+1%]This assigns a number from 1 to 10 to the TT tip variable. Now it's just a simple matter of using a TT switch:
[% SWITCH tip %] [% CASE 1 %] You need to floss more often [% CASE 2 %] Don't Panic [% CASE 3 %] ... [% END %]And that's it, really. Hope this comes in handy for someone :)


Comments
... [% CASE 9 %] You can go directly to a tag by searching for 'tag:yourtag'. You can also search within the apps tagged with that word by adding another word. For example '<a href="[%c.uri_for('/search',{q=>'tag:browser plugin'})%]" >tag:browser plugin</a>'. [% CASE 10 %] ...