Answer the question
In order to leave comments, you need to log in
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>
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;
}
Route::set('rss', 'news/rss')
->defaults(array(
'action' => 'rss',
'directory' => 'index',
'controller' => 'category',
));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question