public function actionRss() { Yii::app()->clientScript->registerLinkTag('alternate', 'application/rss+xml', $this->createUrl('info/6')); require_once 'Zend/Feed.php'; require_once 'Zend/Feed/Atom.php'; $model = Yii::app()->cache->get($this->getUrlId()); if ($model === false) { $criteria = Advertisement::model()->setFetchCondition(20); $model = Advertisement::model()->findAll($criteria); Yii::app()->cache->set($this->getUrlId(), $model, 36000, new CDbCacheDependency("SELECT MAX(id) FROM {{advertisement}}")); } $entries = array(); foreach ($model as $post) { $entries[] = array('title' => $post->title, 'link' => $this->createUrl('info/view', array('id' => $post->id)), 'description' => UtilHelper::strSlice($post->content, 0, 1000), 'lastUpdate' => $post->create); } $feed = Zend_Feed::importArray(array('title' => '悦珂广告栏', 'link' => $this->createUrl(''), 'charset' => 'UTF-8', 'entries' => $entries)); $feed->send(); }
<div class="scrollItem" data-id="scroll-<?php echo $model->id; ?> "> <?php echo Profile::model()->getUserAvatar($model->uid, array('class' => 'left roundSection', 'style' => 'width:50px;padding:10px;'), 50); ?> <span style="color:red;font-weight:bold;"><?php echo $model->title; ?> </span> <?php echo UtilHelper::strSlice(str_replace(' ', '', strip_tags($model->content)), 0, 50); ?> </div>
<?php foreach ($model as $info) { ?> <li> <a href="<?php echo $this->createUrl('/info/view/', array('id' => $info->id, 't' => urlencode($info->title))); ?> " title="<?php echo $info->title; ?> " class="span-4 adLatestTitle">[<?php echo UtilHelper::strSlice(Channel::model()->getChannelName($info->cid), 0, 4); ?> ]<?php echo UtilHelper::strSlice($info->title, 0, 4); ?> </a> <span class="span-8 adLatestDes"> <?php echo UtilHelper::strSlice(str_replace(' ', '', strip_tags($info->content)), 0, 20); ?> </span> <span class="span-2 adLatestDate"><?php echo date('Y-m-d', $info->update); ?> </span> </li> <?php }
<div class="left"> <?php if ($preview) { $string = strlen(strip_tags($preview->title)) ? strip_tags($preview->title) : date('y-m-d', $preview->create); ?> 前一篇:<?php echo CHtml::link(UtilHelper::strSlice($string, 0, $this->length), array($this->linkview, 'id' => $preview->id, 't' => urlencode($preview->title)), array('title' => $preview->title)); } else { ?> 已经是第一篇了! <?php } ?> </div> <div class="right"> <?php if ($next) { $string = strlen(strip_tags($next->title)) ? strip_tags($next->title) : date('y-m-d', $next->create); ?> 前一篇:<?php echo CHtml::link(UtilHelper::strSlice($string, 0, $this->length), array($this->linkview, 'id' => $next->id, 't' => urlencode($next->title)), array('title' => $next->title)); } else { ?> 已经是第一篇了! <?php } ?> </div>
/** * User $user * 获取广告牌简称,即只取地区名的前两个字作为地区广告牌名称 */ public function getAreaBrandName($id) { $region = self::model()->getAreaName($id); return UtilHelper::strSlice($region, 0, 2, 'utf-8', false); }