SimplePie html rssfeeds Codeigniter

发布于 2024-08-09 02:01:26 字数 134 浏览 4 评论 0原文

我想问一下,我有一个 div,想放置来自 BBC 或 CNN 的 RSS 提要。现在可以了,但我想对传入的提要进行分页,一次显示 5 个提要,单击链接时显示其他提要。

我现在开始编写代码,但我希望我能得到灵感或者有一个可以从中收集的例子。

I wanted to ask, I have a div that I would want to place RSS feeds from the BBC or CNN. Now that works but I wanted to paginate the feeds that come in, display 5 at a time with the others showing when the links are clicked.

I am starting to write the code now but I was hoping I would get either inspiration or have an example I could glean from.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

世俗缘 2024-08-16 02:01:26

我使用过 Haughin 的 Simple CodeIgniter 库。使用起来非常简单。

$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>";

您可以在此处查看代码。

I've used Haughin's Simple CodeIgniter Library. It's very simple to use.

$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>";

You can check out the code here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文