Example #1
0
	                <p>
	                    <?php 
echo Html::a(Yii::t('extend', 'Create Link'), ['create'], ['class' => 'btn btn-success']);
?>
	                </p>
	             -->
            	<?php 
Pjax::begin();
?>
				<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'options' => ['class' => 'grid-view box-body table-responsive no-padding'], 'tableOptions' => ['class' => 'table table-hover table-striped table-bordered'], 'headerRowOptions' => [], 'footerRowOptions' => [], 'showHeader' => true, 'showFooter' => false, 'layout' => "{summary}\n{errors}\n{items}\n{pager}", 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'name', 'format' => 'raw', 'value' => function ($model) {
    $length = Yii::$app->params['config']['config_site_title_length'];
    $title = StringHelper::truncate($model->name, $length);
    //'<span class="fa fa-list-ol"></span> '.
    return Html::a($title, ['update', 'id' => $model->id], ['data-pjax' => '0']);
}], ['attribute' => 'link_type_id', 'filter' => ArrayHelper::map(LinkType::find()->alive()->all(), 'id', 'name'), 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    return $model->linkType->name;
}], 'link_url:url', ['attribute' => 'order', 'format' => 'raw', 'value' => function ($model) {
    return Html::activeTextInput($model, 'order', ['style' => 'width:50px', 'data-id' => $model->id, 'id' => '', 'class' => 'cms-order']);
}], ['attribute' => 'status', 'format' => 'html', 'filter' => [Link::STATUS_YES => Yii::t('common', 'Yes'), Link::STATUS_NO => Yii::t('common', 'No')], 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    $on = Html::a('<small class="label bg-green">' . Yii::t('common', 'Yes') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('common', 'Update Status'), 'data-pjax' => '0']);
    $off = Html::a('<small class="label bg-red">' . Yii::t('common', 'No') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('common', 'Update Status'), 'data-pjax' => '0']);
    return $model->status ? $on : $off;
}], 'created_at:datetime', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'header' => Yii::t('common', 'Opration')]]]);
?>
				<?php 
Pjax::end();
?>
                </div>
                
            </div>
Example #2
0
 /**
  * Finds the LinkType model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return LinkType the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = LinkType::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 /**
  * 一对一
  */
 public function getLinkType()
 {
     return $this->hasOne(LinkType::className(), ['id' => 'link_type_id']);
 }
Example #4
0
/* @var $model common\models\extend\Link */
/* @var $form yii\widgets\ActiveForm */
if ($model->isNewRecord) {
    $model->status = true;
    $model->order = 10;
}
?>

<div class="row link-form">
    <div class="col-md-12">
        <?php 
$form = ActiveForm::begin(['layout' => 'horizontal', 'fieldConfig' => ['template' => "{label} {beginWrapper} {input} {hint} {error} {endWrapper}", 'horizontalCssClasses' => ['label' => 'col-sm-2', 'offset' => 'col-sm-offset-2', 'wrapper' => 'col-sm-8', 'error' => '', 'hint' => '']]]);
?>
    
        <?php 
echo $form->field($model, 'link_type_id')->dropDownList(ArrayHelper::map(LinkType::find()->alive()->all(), 'id', 'name'));
?>

	    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
	    
	    <?php 
echo $form->field($model, 'link_url')->hint('<i class="fa fa-info-circle"></i> ' . Yii::t('extend', 'Example:http://www.turen.pw'))->textInput(['maxlength' => true]);
?>
	    
	    <?php 
echo $form->field($model, 'description')->textarea(['maxlength' => true]);
?>
	    
	    <?php 
Example #5
0
    $params = ['tag' => 'ul', 'encodeLabels' => false, 'itemTemplate' => "<li>{link}<span class=\"jian\">></span></li>\n", 'options' => ['class' => 'breadcrumb clearfix'], 'homeLink' => ['label' => '首页', 'url' => Yii::$app->homeUrl], 'links' => $this->params['breadcrumbs']];
    echo Breadcrumbs::widget($params);
}
?>
		
        <?php 
echo $content;
?>
	</div>
	
	<div class="foot-top clearfix mar-t18">
		<div class="foot-top-content clearfix">
			<div class="n_foot-box">
		    	<?php 
$links = Link::find()->select(Link::tableName() . '.*')->joinWith(['linkType' => function ($query) {
    $query->where([LinkType::tableName() . '.short_code' => 'site_links']);
}])->active()->all();
//友情链接
?>
		        <ul class="tit_tab clearfix">
		        	<li class="on">友情链接</li>
		        </ul>
		        <div class="main-link-box clearfix">
		            <ul class="clearfix">
		            	<?php 
foreach ($links as $link) {
    ?>
		                <li>
		                    <?php 
    echo Html::a($link->name, [$link->link_url], ['target' => '_blank']);
    ?>