News::model PHP Method

model() public static method

Returns the static model of the specified AR class.
public static model ( string $className = __CLASS__ ) : News
$className string
return News the static model class
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

Usage Example

Example #1
0
 public function actionRss()
 {
     // disabling web log
     foreach (Yii::app()->log->routes as $route) {
         if ($route instanceof CWebLogRoute) {
             $route->enabled = false;
         }
     }
     Yii::import('ext.feed.*');
     $feed = new EFeed();
     $feed->title = Yii::app()->name . ' | ' . Yii::t('newsModule.common', 'Nouvelles');
     $feed->description = Yii::app()->name . ' | ' . Yii::t('newsModule.common', 'Nouvelles');
     $feed->addChannelTag('language', Yii::app()->language);
     $feed->addChannelTag('pubDate', date(DATE_RSS, time()));
     $feed->addChannelTag('link', $this->createAbsoluteUrl('index'));
     if ($news = News::model()->findAll(array('order' => 'date DESC', 'limit' => 25, 'condition' => "date <= '" . date('Y-m-d H:i:s') . "' AND section_id = " . Yii::app()->cms->currentSectionId))) {
         foreach ($news as $new) {
             $item = $feed->createNewItem();
             $item->title = $new->title;
             $item->link = $this->createAbsoluteUrl('detail', array('n' => $new->title_url));
             $item->date = $new->date;
             if (!empty($new->image)) {
                 $item->description = '<div style="margin-bottom: 1em;"><img src="' . Yii::app()->request->hostInfo . Yii::app()->request->baseUrl . '/' . $new->imageHandler->dir . '/' . Helper::encodeFileName(Helper::fileSuffix($new->image, 's')) . '" alt="' . CHtml::encode($new->title) . '" /></div><div>' . CHtml::encode($new->summary) . '</div>';
             } else {
                 $item->description = CHtml::encode($new->summary);
             }
             $feed->addItem($item);
         }
     }
     $feed->generateFeed();
     Yii::app()->end();
 }
All Usage Examples Of News::model