<?php echo $this->createAbsoluteUrl('', array("id" => $id)) . "<br>"; echo $this->createUrl('', array("id" => $id)); ?>
На выходе:
- http://bio/index.php?r=ad/view&id=
- /index.php?r=ad/view&id=
<?php echo $this->createAbsoluteUrl('', array("id" => $id)) . "<br>"; echo $this->createUrl('', array("id" => $id)); ?>
public function actionView($id) { $model = $this->loadModel($id); if(!Yii::app()->request->cookies[$id]) { $cookie = new CHttpCookie($id, true); $cookie->expire = time() + 3600; Yii::app()->request->cookies[$id] = $cookie; //сохраняем в БД в поле "hits" (не забудьте создать) $model->saveCounters(array('hits' => 1)); } $this->render('view', array('model'=>$model,)); }
<a href="#" rel="tooltip" data-placement="left" data-trigger = "hover" title="" data-html="true" data-title="<strong>placement</strong><br>Tooltip on left">Tooltip</a>
<?php Yii::app()->clientScript->registerScript("", "$('.ipopover').popover();", CClientScript::POS_READY) ?>
<?php echo CHtml::Link('<i class="icon-info-sign"></i>', null, array(
'class' => 'ipopover',
'data-trigger' => 'hover',
'data-title' => 'Your title',
'data-content' => 'Your content',
))?>
composer.phar require --prefer-dist yiisoft/yii2-jui "*"
composer require kartik-v/yii2-widgets "*"
public function actionNews() { $query = News::find()->count(); $pages = new Pagination([ 'totalCount' => $query, 'defaultPageSize' =>10, ]); $models = News::find()->offset($pages->offset)->limit($pages->limit)->orderBy("date DESC")->all(); return $this->render('news', [ 'models' => $models, 'pages' => $pages, ]); }
<div class="row"> <div class="col-md-7"> <?php foreach ($models as $model): ?> <h1 class="page-header"><?= $model->title ?> <small> <?php echo $model['date'] ?></small></h1> <p><?= $model->article ?></p> <?php endforeach; ?> </div> <div class="col-md-5"> <?PHP // display pagination echo LinkPager::widget(['pagination' => $pages,]); var_dump($pages); ?> </div> </div>