Home

Previous Entry | Next Entry

Making the iusethis "did you know" function.

  • Jul. 30th, 2006 at 10:04 AM
me in B&W
(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

(Anonymous) wrote:
Aug. 6th, 2006 08:24 am (UTC)
Or even easier!
We are doing this for a "Did you know?" on http://www.suretecsystems.com (new site launch not ready yet), and missed out a lot of Did You Knows below.
[% USE Math %]

[% did_you_know =  [ '

Open Source can provide you with VoIP

', '

Open Source can provide you with Secure E-mail

', '

Open Source can help you with your customers

', ] %] [% did_you_know.${Math.rand(did_you_know.size)} %]
[info]marcusramberg wrote:
Aug. 8th, 2006 09:31 am (UTC)
Re: Or even easier!
Well, the advantage of that is obviously that you don't have to update $maxnum when you add another notice, but I think using a list like that looks a little more messy, specially if you need to use html formatting or server side includes in your stuff. For instance,
...
[% 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 %]
...

Advertisement

Latest Month

June 2009
S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930    

Page Summary

Powered by LiveJournal.com
Designed by Tiffany Chow