Lasso Soft Inc. > Home

[quoteoftheday]

Linkquoteoftheday
AuthorJason Huck
CategoryUtility
Version8.x
Licensehttp://opensource.org/licenses/artistic-license.php
Posted11 Jul 2006
Updated11 Jul 2006
More by this author...

Description

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].

Sample Usage

var('qotd') = quoteoftheday;

'' + $qotd->find('quote') + '
\n'; '-- ' + $qotd->find('author') + '\n';

Source Code

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;

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft