/** * Displays a particular model. * 如果查询没有子地区,则跳转到当前地区 * @param integer $id the ID of the model to be displayed */ public function actionView($id) { $model = $this->loadModel($id); UtilHelper::writeToFile($model->attributes); if ($model->children == null) { //如果已有人开启了广告栏,则跳转到对应广告栏首页,否则就回到本地首页 if ($model->forerunner) { // 设置cookie信息 $cookies = new CHttpCookie('area', serialize($model->attributes)); $cookies->expire = time() + 60 * 60 * 24 * 30; Yii::app()->request->cookies['area'] = $cookies; $link = $this->createUrl('/site/index', array('area' => Region::model()->getUserArea()->short, 'id' => $model->id)); } else { $link = $this->createUrl('/site/mention', array('region' => $model->region)); } echo 'fail_' . $link; } else { $pinyin = new PinYin(); // echo '<ul>'; foreach ($model->children as $data) { // echo '<li>'; echo CHtml::link($data->region, array('/region/view', 'id' => $data->id, 'area' => $pinyin->words2Short($data->region, 1)), array('onclick' => 'uu.loadRegion($(this));return false;')); // echo '</li>'; } // echo '</ul>'; } }
private function showLinks() { $pinyin = new PinYin(); $data = $this->getData(); foreach ($data as $item) { echo CHtml::link($item->region, array('/region/view', 'id' => $item->id, 'area' => $pinyin->words2Short($item->region, 1)), array('onclick' => 'uu.loadRegion($(this));return false;')); } }
<?php $pinyin = new PinYin(); $user = User::model()->findByPk($data->forerunner); $short = $pinyin->words2Short(Region::model()->getAreaName($user->profiles->county)); ?> <div class="roundSection left" style="width:190px;text-align:center;margin:0 20px;padding:5px;"> <?php echo CHtml::link(CHtml::image('/public/images/logo.png', Region::model()->getAreaBrandName($user->profiles->county)), array('site/index', 'id' => $user->profiles->county, 'area' => Region::model()->getAreaBrandShortName($user->profiles->county)), array('class' => 'left', 'title' => Profile::model()->getUserAddress($data->forerunner, '>'), 'style' => 'padding:10px;padding:0px;font-size:60px;font-family:TTF;font-weight:bolder;overflow:hidden;')); ?> <div class="right" style="position:absolute;top:50px;right:5px;font-size:12px;"> <?php echo Region::model()->getAreaBrandName($user->profiles->county); ?> 广告栏 </div> <hr /> <?php echo date('m月d日'); ?> </div>
/** * 获取广告简写 * @param unknown_type $id */ public function getAreaBrandShortName($id) { $pinyin = new PinYin(); return $pinyin->words2Short(self::getAreaBrandName($id)); }