[quoteoftheday]

Description

Link: [quoteoftheday]
Author: Jason Huck
Category: Utility
Version: 8.x
License:
Posted: Jul. 11, 2006
Updated: Jan. 01, 0001
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].

Parameters

none


Sample Usage

var('qotd') = quoteoftheday;

'<strong>' + $qotd->find('quote') + '</strong><br>\n';
'-- <a href="' + $qotd->find('link') + '">' + $qotd->find('author') + '</a>\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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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

none

Email:


Password:



Newest

Most Popular