Ok, I'm gonna try. Since I'm using codeigniter as a framework some
things are a bit awkward to explain.
I have one controller which passes all the data to a view. The view
process and display the data (is a pretty basic MVC structure, without
the model)
The controller stores the RSS address in an array:
$data ['rsstwitter'] = "
http://twitter.com/statuses/user_timeline/
55573.rss";
And then calls an helper function, passing the address and the number
of items I want to fetch:
$rss ['twitter'] = infoblock($data ['rsstwitter'], 5);
The helper function then uses simplepie to fetch the rss that I want:
function infoblock($url, $count)
{
$CI =& get_instance();
$CI->simplepie->set_feed_url($url);
$CI->simplepie->init();
$CI->simplepie->handle_content_type();
$CI->simplepie->strip_htmltags('img');
foreach ($CI->simplepie->get_items(0,$count) as $item):
$arr[] = array(
'bloglink' =>$CI->simplepie->get_permalink(),
'itemtitle' => $item->get_title(),
'itemdate' => $item->get_date('YmdHis'),
'itemplink' => $item->get_permalink(),
);
endforeach;
return $arr;
}
And store it in an array which will be passed to the view and
processed, like this:
<div id="twitter">
<h2 class="content">Twitter <a href="<?=$twitter[0]['bloglink'];?>"
title="Go to Twitter">»</a></h2>
<ul>
<?php
$i=1;
foreach ($twitter as $val) :
?>
<li class="link<?=$i?>"><a href="<?=$val['itemplink'];?>" title="<?=
$val['itemtitle'];?>"><?=character_limiter(substr($val['itemtitle'],
7), 40);?></a></li>
<?
$i++;
endforeach;
?>
</ul>
<a href="<?=$rsstwitter?>" title="RSS Feed for Twitter" ><img src="<?
=base_url();?>/images/feed.gif" alt="RSS Feed for Twitter"
class="feed" /></a>
</div>
The tag you see are a codeigniter feature.
The character limiter and the substring are used to cut off the
username (kurai) and to limit the number of character shown.
I hope it's clearer now...
Thank you for any advice.