A
A
Anton2015-08-20 07:30:05
Kohana
Anton, 2015-08-20 07:30:05

Making an rss news feed for kohana 3.1, how to display news photos?

Hello, I implemented an rss channel for a news site, I display rss news, but I can’t display a photo.
Can you please tell me how to display images?
To display pictures in the news itself, I have the following code:

<a href="/news/<?=$new['alias']?>">
<?php if($new['image']):?>
<img src="/media/uploads/small/small_<?php echo ($new['image'])?>" />
<?php else:?>
<img src="/media/uploads/noimage.jpg"/>
<?php endif;?>
</a>

I share a working rss code for news.

/application/classes/controller/index
контроллер категорий category.php в нем акшион rss
public function action_rss()
{
  
$info = array(
'title' => 'Новости приморского края ',
'language' => 'ru',
'description' => 'Новости приморского края и т.д',
'link' => 'http://сайт.ru/news/rss',
'pubDate' => time());

$new = ORM::factory('new')
->where('status','=',1)
->find_all();

$items = array();

$siteurl = 'http://сайт.ru';

foreach ($new as $news)
{
if($news->id == '1')
{
$url = $siteurl.'/news/'.$news->alias.'';
$items[] = array(
'title' => $news->prname,
'link' => $url,
'guid' => $url,
'description' => $news->shortdescription,
'pubDate' => $news->time.' '.$news->date,
);
}
else
{
$url = $siteurl.'/news/'.$news->alias.'';
$items[] = array(
'title' => $news->prname,
'link' => $url,
'guid' => $url,
'description' => $news->shortdescription,
'pubDate' => $news->time.' '.$news->date,

);
}
}

header('Content-Type: text/xml');

echo feed::create($info, $items);
die;
}

для того что бы работал rss по ссылке http://сайт.ru/news/rss устанавливаем маршрут.
/application
bootstrap.php
Route::set('rss', 'news/rss')
 ->defaults(array(
  'action' => 'rss',
  'directory'  => 'index',
  'controller' => 'category',
 ));

Все rss работает, проверено.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question