dev-master
9999999-devcreate rss uses by array or db query data
GPL-2.0
The Requires
by seifzadeh
extension yii2 rss
create rss uses by array or db query data
create rss uses by array or db query data, (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist persianyii/yii2-rss "dev-master"
or add, (*4)
"persianyii/yii2-rss": "dev-master"
to the require section of your composer.json
file., (*5)
Once the extension is installed, simply use it in your code by :, (*6)
```php $rss = new \persianyii\rss\Rss();, (*7)
$items = []; $items['atomLinkHref'] = ''; $items['title'] = 'My News'; $items['link'] = 'http://mysite.com/news.php'; $items['description'] = 'The latest news about web-development.'; $items['language'] = 'en-us'; $items['generator'] = 'PHP RSS Feed Generator'; $items['managingEditor'] = 'editor@mysite.com (Alex Jefferson)'; $items['webMaster'] = 'webmaster@mysite.com (Vagharshak Tozalakyan)'; $posts = (new \yii\db\Query())-> select(['title', 'content', 'create_time'])-> from('tbl_post')-> where(['status' => '1'])-> limit(20)-> all(); $items['items'] = []; foreach ($posts as $k => $v) { $items['items'][] = [ 'title' => $v['title'], 'description' => substr($v['content'], 0, 500), 'link' => 'http://yii.com/post/show/' . $v['title'] . '.html', 'pubDate' => date('Y/m/d H:i', $v['create_time']), ]; } header('Content-Type: text/xml'); echo $rss->createFeed($items);```
create rss uses by array or db query data
GPL-2.0
extension yii2 rss