Встроенный метод Kohana для помощи в разработке RSS-канала.

StackOverflow https://stackoverflow.com/questions/937921

  •  06-09-2019
  •  | 
  •  

Вопрос

Я обнаружил, что есть помощник, помогающий анализировать RSS-каналы в системе Kohana.

Есть ли кто-нибудь, кто поможет его создать?

Это было полезно?

Другие советы

Сделайте это с помощью create() метод Feed урок в Кохане 3.Вы найдете его код по следующему адресу:

система/классы/kohana/feed.php

Вам нужно будет определите информацию о канале и элементы его ленты как минимум.

$info = array(
           'title' => 'Dark into the Narwhal',
           'pubDate' => date("D, d M Y H:i:s T"),
           'description' => 'Eating bacon, taking names and leaving fortunes',
           'link' => 'http://example.com/',
           'copyright' => 'The Narwhal Peon',
           'language' => 'en-us',
           'ttl' => '7200',
        );

$items = array(
           array(
               'title' => 'We journey with watermelon helmets',
               'link' => 'blog/journey-with-watermelon-helmets',
               'description' => 'Dawn breaks and the wind follows soon after. 
                                 We have found our supplies run low.',
           ),

            //-- and the other posts you want to include
         ); 

Затем подключите эти данные к методу для генерации XML:

$xml = Feed::create($info, $items);

Что даст вам это, когда вы echo его или передайте в соответствующее представление:

<?xml version="1.0" encoding="UTF-8"?>
 <rss version="2.0">
  <channel>
  <title>Dark into the Narwhal</title>
  <pubDate>Fri, 21 Dec 2012 13:32:42 EST</pubDate>
  <description>Eating bacon, taking names and leaving fortunes</description>
  <link>http://example.com/</link>
  <copyright>The Narwhal Peon</copyright>
  <language>en-us</language>
  <ttl>7200</ttl>
  <generator>KohanaPHP</generator>
  <item>
    <title>We journey with watermelon helmets</title>
    <link>http://example.com/blog/journey-with-watermelon-helmets</link>
    <description>Dawn breaks and the wind follows soon after. 
                 We have found our supplies run low.</description>
  </item>

  <!-- the other posts will be here -->

  </channel>
</rss>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top