twittoris Posted April 4, 2010 Share Posted April 4, 2010 I have a page which formats a lists of rss feeds I have put together. Is there a way I can program a php script to read each rss feed entry and output each entry into its own html file? So I have 15 feeds being read and formatted i should have 15 html files created. Quote Link to comment Share on other sites More sharing options...
twittoris Posted April 4, 2010 Author Share Posted April 4, 2010 Here is my index.php file <?php require_once('Smarty.class.php'); require_once('config.php'); if(!is_writable('smarty_cache') && !is_writable('smarty_compile')) { if(function_exists('chmod')) { if(!(chmod('smarty_cache', 0777) && chmod('smarty_compile', 0777))) print 'The directories <code>smarty_cache</code> and <code>smarty_compile</code> are not writable and this problem could not be fixed automatically. Please chmod these directories to 755.'; } else print 'The directories <code>smarty_cache</code> and <code>smarty_compile</code> are not writable and this problem could not be fixed automatically. Please chmod these directories to 755.'; } require_once('rss_fetch.inc'); $smarty = new Smarty; $smarty->assign('site_name', $config['site_name']); $smarty->assign('adsense_id', $config['adsense_id']); $smarty->assign('disable_tooltips', $config['disable_tooltips']); $smarty->assign('disable_search', $config['disable_search']); $smarty->assign('links_new_window', $config['links_new_window']); $smarty->template_dir = 'template'; $smarty->compile_dir = 'smarty_compile'; $smarty->cache_dir = 'smarty_cache'; $feeds = file('feeds.txt'); $data = array(); error_reporting(0); foreach($feeds as $feed) { $i = 0; $title = ''; if(preg_match('/^([^ ]*) (.*)$/', $feed, $m)) { $feed = $m[1]; $title = $m[2]; } else $feed = trim($feed); $fetcher = fetch_rss($feed); if($fetcher->items) { array_push($data, array('title' => ($title?$title:$fetcher->channel['title']))); $data[(count($data)-1)]['link'] = $fetcher->channel['link']; $data[(count($data)-1)]['links'] = array(); foreach($fetcher->items as $item) { if($i++ < $config['items_per_feed']) array_push($data[(count($data)-1)]['links'], array('title' => ($config['max_headline_length'] && strlen($item['title']) > $config['max_headline_length'])?(substr($item['title'], 0, $config['max_headline_length']-3).'...')$item['title']), 'link' => $item['link'], 'desc' => preg_replace('/<([^>]*)>/', '',$item['summary']?$item['summary']$item['atom_content']?$item['atom_content']:$item['description'])), 'id' => ($id++)+0)); } } } $smarty->assign('data', $data); $smarty->display('index.tpl'); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.