function init() { parent::init(); //上一级 可支持无限级 分类 //上一级 可支持无限级 分类 $data = ContentCategory::model()->findAll(array('order' => 'sort_order asc, category_id asc')); $parent = CHtml::tag('option', array('value' => 0), F::t('Please Select')); $this->parent = $parent . F::toTree($data, $model->cate_id, 'category_id', 'parent_id', 'name', 1); }
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('action' => Yii::app()->createUrl($this->route), 'method' => 'get')); echo $form->dropDownListControlGroup($model, 'parent_id', CHtml::listData(ContentCategory::model()->findAll(array('condition' => 'parent_id=0', "order" => "title")), 'id', 'title'), array('empty' => '--please select--', 'class' => 'span5')); echo $form->textFieldControlGroup($model, 'title', array('class' => 'span5', 'maxlength' => 255)); ?> <div class="form-actions"> <?php echo TbHtml::submitButton('Search', array('color' => TbHtml::BUTTON_COLOR_PRIMARY)); ?> <?php echo TbHtml::resetButton('Reset', array('color' => TbHtml::BUTTON_COLOR_INFO)); ?> </div> <?php $this->endWidget();
/** * Retrieves Category name by ID. * @return string. */ public function getCategoryName($id) { $value = ContentCategory::model()->findByAttributes(array('id' => $id)); if (empty($value->title)) { return null; } else { return $value->title; } }
public function getHelp() { $cri = new CDbCriteria(array('condition' => 'parent_id = 3')); $ContentCategory = ContentCategory::model()->findAll($cri); return $ContentCategory; }
public static function get_category_list_menu($category) { $array = ContentCategory::model()->findAll(array('condition' => 'published=1 AND parent_id=' . (int) $category, 'order' => 'title ASC', 'limit' => '10')); echo '<ul class="dropdown-menu"> '; foreach ($array as $key => $value) { echo '<li>' . CHtml::link($value['title'], array('content/category', 'id' => $value['id']), array('style' => 'font-size:14px;')) . '</li>'; } echo '</ul>'; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = ContentCategory::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
// }) // }) </script> <div style="width:120px;right:7px;top:170px;" class="shop_xf shop_right J_TBox"> <div class="J_TWidget" style="visibility:visible;"> <ul class="nav ks-switchable-nav"> <li class="selected"><img src="http://img02.taobaocdn.com/bao/uploaded/i2/T1sQG6Xi4iXXb1upjX.jpg?noq=y&rid=37631133&file_path=-djzk.jpg"></li> <li class="ks-none"></li> </ul> <div class="ks-switchable-content"> <div class="bd" style="display: block;"> <div class="bk time"><h3>在线时间</h3><span>09:00-23:00</span></div> <div class="kf bk"> <?php $cri = new CDbCriteria(array('condition' => 'parent_id = 8')); $service_category = ContentCategory::model()->findAll($cri); foreach ($service_category as $sc) { ?> <h3><?php echo $sc->name; ?> </h3> <ul> <?php $cri = new CDbCriteria(array('condition' => 'category_id =' . $sc->category_id)); $CustomerService = CustomerService::model()->findAll($cri); foreach ($CustomerService as $cs) { ?> <li><span><?php echo $cs->nick_name; ?>