[yahoo_customnews]

Description

Link: [yahoo_customnews]
Author: Jim Van Heule
Category: Utility
Version: 8.x
License: Public Domain
Posted: Jun. 16, 2008
Updated: Jun. 16, 2008
More by this author...

Given a valid feed name for Yahoo! Custom News, returns the current feed data as an array of maps. Use keywords using spaces between words.

This tag does not handle standard Yahoo news feeds. Yahho_News should be used for those.

Credit: Based on Jason Huck's yahoo_news tag and modified to handle custom news.

Parameters

none


Sample Usage

[//lasso
'<form action="" method="post">';
'<input type="text" name="newsitem" value="'; Action_Param:'newsitem'; '">';
'<input type="submit" name="action" value="Search" />';
'</form>';
'Customize your news search with keywords';

var('mynews') = Yahoo_CustomNews(Action_Param:'newsitem');

// $mynews;
If:$mynews -> (Size) > 0;
	iterate($mynews, local('i'));
		'<h4><a href="' + #i->find('link') + '" target="_blank">' + #i->find('title') + '</a></h4>\n';
		'<small>' + #i->find('pubDate')->format('%D') + '</small>\n';
		'<p>' + #i->find('description') + '</p>\n';
	/iterate;
/If;
]
						

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
38
39
40
41
42
43
44
45
46
47
[//lasso
define_tag(
	'customnews',
	-namespace='yahoo_',
	-req='feed',
	-priority='replace',
	-description='Retrieves the specified news feed from Yahoo! Custom News.'
);
	local('out' = array);
	protect;
		#feed -> (Replace: ' ', '+');
		local('data') = xml_tree(include_url('http://news.search.yahoo.com/news/rss?p=' + #feed + '&ei=UTF-8&fl=0&x=wrt'));
		
		handle_error;
			return;
		/handle_error;
	/protect;
	
	local('nodes') = array(
		'title',
		'link',
		'guid',
		'pubDate',
		'description',
		'content',
		'text',
		'credit'
	);
	
	iterate(#data->channel->item, local('i'));		
		local('temp' = map);
		
		iterate(#nodes, local('n'));
			protect;
				local('raw') = decode_html(#i->getnode(#n)->contents);
				#raw->trim;
				#n == 'pubDate' ? #raw = date(#raw, -format='%a, %d %b %Y %H:%M:%S GMT');	// Thu, 20 Jul 2006 16:22:22 GMT
				#temp->insert(#n = #raw);
			/protect;
		/iterate;
		
		#out->insert(#temp);
	/iterate;
	
	return(#out);
/define_tag;
]

 

Comments

none

Email:


Password:



Newest

Most Popular