2017 © Pedro Peláez
 

yii2-extension yii2-rss

Yii2 RSS extension adds RSS-feed to your site

image

balrok/yii2-rss

Yii2 RSS extension adds RSS-feed to your site

  • Tuesday, June 19, 2018
  • by balrok
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 16 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Yii2 RSS extension

Yii2 RSS extension adds RSS-feed to your site, (*1)

This is a fork of https://github.com/zelenin/yii2-rss because the original author abandoned it and there was a bug with sending headers., (*2)

Installation

Composer

The preferred way to install this extension is through Composer., (*3)

Either run, (*4)

php composer.phar require balrok/yii2-rss "~0.1"

or add, (*5)

"balrok/yii2-rss": "~0.1"

to the require section of your composer.json, (*6)

Usage

Add action to your controller:, (*7)

public function actionRss()
{
    $dataProvider = new ActiveDataProvider([
        'query' => Post::find()->with(['user']),
        'pagination' => [
            'pageSize' => 10
        ],
    ]);

    $response = Yii::$app->getResponse();
    $headers = $response->getHeaders();

    $headers->set('Content-Type', 'application/rss+xml; charset=utf-8');

    echo \balrok\yii\extensions\Rss\RssView::widget([
        'dataProvider' => $dataProvider,
        'channel' => [
            'title' => function ($widget, \balrok\Feed $feed) {
                    $feed->addChannelTitle(Yii::$app->name);
            },
            'link' => Url::toRoute('/', true),
            'description' => 'Posts ',
            'language' => function ($widget, \balrok\Feed $feed) {
                return Yii::$app->language;
            },
            'image'=> function ($widget, \balrok\Feed $feed) {
                $feed->addChannelImage('http://example.com/channel.jpg', 'http://example.com', 88, 31, 'Image description');
            },
        ],
        'items' => [
            'title' => function ($model, $widget, \balrok\Feed $feed) {
                    return $model->name;
                },
            'description' => function ($model, $widget, \balrok\Feed $feed) {
                    return StringHelper::truncateWords($model->content, 50);
                },
            'link' => function ($model, $widget, \balrok\Feed $feed) {
                    return Url::toRoute(['post/view', 'id' => $model->id], true);
                },
            'author' => function ($model, $widget, \balrok\Feed $feed) {
                    return $model->user->email . ' (' . $model->user->username . ')';
                },
            'guid' => function ($model, $widget, \balrok\Feed $feed) {
                    $date = \DateTime::createFromFormat('Y-m-d H:i:s', $model->updated_at);
                    return Url::toRoute(['post/view', 'id' => $model->id], true) . ' ' . $date->format(DATE_RSS);
                },
            'pubDate' => function ($model, $widget, \balrok\Feed $feed) {
                    $date = \DateTime::createFromFormat('Y-m-d H:i:s', $model->updated_at);
                    return $date->format(DATE_RSS);
                }
        ]
    ]);
}

Authors

The Versions

19/06 2018

dev-master

9999999-dev https://github.com/balrok/yii2-rss

Yii2 RSS extension adds RSS-feed to your site

  Sources   Download

MIT

The Requires

 

by Carl Mai

yii2 feed rss

19/06 2018

0.1.3

0.1.3.0 https://github.com/balrok/yii2-rss

Yii2 RSS extension adds RSS-feed to your site

  Sources   Download

MIT

The Requires

 

by Carl Mai

yii2 feed rss

19/06 2018

0.1.2

0.1.2.0 https://github.com/balrok/yii2-rss

Yii2 RSS extension adds RSS-feed to your site

  Sources   Download

MIT

The Requires

 

by Carl Mai

yii2 feed rss

05/11 2015

0.1.1

0.1.1.0 https://github.com/zelenin/yii2-rss

Yii2 RSS extension adds RSS-feed to your site

  Sources   Download

MIT

The Requires

 

yii2 feed rss

07/12 2014

0.0.4

0.0.4.0 https://github.com/zelenin/yii2-rss

Yii2 RSS extension adds RSS-feed to your site

  Sources   Download

MIT

The Requires

 

yii2 feed rss

03/12 2014

0.0.3

0.0.3.0 https://github.com/zelenin/yii2-rss

Yii2 RSS extension adds RSS-feed to your site

  Sources   Download

MIT

The Requires

 

yii2 feed rss

02/11 2014

0.0.2

0.0.2.0 https://github.com/zelenin/yii2-rss

Yii2 RSS extension adds RSS-feed to your site

  Sources   Download

MIT

The Requires

 

yii2 feed rss

05/07 2014

0.0.1

0.0.1.0 https://github.com/zelenin/yii2-rss

Yii2 RSS extension adds RSS-feed to your site

  Sources   Download

MIT

The Requires

 

yii2 feed rss