Link | quoteoftheday |
Author | Jason Huck |
Category | Utility |
Version | 8.x |
License | http://opensource.org/licenses/artistic-license.php |
Posted | 11 Jul 2006 |
Updated | 11 Jul 2006 |
More by this author... |
This tag returns a map of a random quote from the QuotationsPage.com daily feed. It caches the result for 24 hours (the feed only changes daily). The map contains author, quote, and link separately so that you can control the formatting. Requires [xml_tree].
var('qotd') = quoteoftheday; '' + $qotd->find('quote') + '
\n'; '-- ' + $qotd->find('author') + '\n';
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define_tag( 'quoteoftheday', -priority='replace', -description='Returns a Quote of the Day from the QuotationsPage.com feed.' ); local('exp') = (60 * 60 * 24); if(!cache_exists( -name='Quote_of_the_Day', -expires=#exp)); local('quotes') = xml_tree( string( include_url('http://www.quotationspage.com/data/qotd.rss') ) ); local('index') = math_random( -lower=1, -upper=#quotes->channel->item->size ); local('firstquote') = @#quotes->channel->item(#index); global('quoteoftheday') = map( 'author' = #firstquote->title->contents, 'quote' = #firstquote->description->contents->split('"')->second, 'link' = #firstquote->link->contents ); cache_object( -name='Quote_of_the_Day', -content=$quoteoftheday, -expires=#exp ); /if; return($quoteoftheday); /define_tag;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft