2009-10-25 3 views
3

BBC 나 CNN의 RSS 피드를 배치 할 div가 있습니다. 이제는 작동하지만 링크를 클릭 할 때 표시되는 다른 링크와 함께 한 번에 5 개씩 표시하는 피드를 페이지 매기기를 원했습니다.SimplePie html rssfeeds Codeigniter

나는 지금 코드를 작성하기 시작했지만 나는 영감을 얻거나 내가 모을 수있는 모범을 얻길 바랐다.

답변

0

나는 Haughin's Simple CodeIgniter Library을 사용했습니다. 사용하기가 매우 쉽습니다.

$this->load->library('simplepie'); 
$this->simplepie->set_feed_url('http://feeds.haughin.com/haughin'); 
$this->simplepie->set_cache_location(APPPATH.'cache/rss'); 
$this->simplepie->init(); 
$this->simplepie->handle_content_type(); 

$data['rss_items'] = $this->simplepie->get_items(); 

echo "<li>"; 
foreach($rss_items as $item) { 
    echo "<li>"; 
    echo "<a href='" .$item->get_link() . "'>"; 
    echo $item->get_title(); 
    echo "</a>"; 
    echo "</li>"; 
} 
echo "</li>"; 

코드 here을 확인할 수 있습니다.

+0

누구나 $ item-> get_title()의 값을 가져 와서 변수에 추가하는 방법을 알고 있습니까? 그것은 간단하게 들리지만 나는 다음과 같습니다. "치명적인 오류 : 162 행의 /home/seedetai/public_html/testseedetail/application/models/post_model.php에 배열로 SimplePie_Item 유형의 객체를 사용할 수 없습니다." – Adamantus