Esempio n. 1
0
 protected function renderPageButton($label, $page, $class, $disabled, $active)
 {
     $options = ['class' => $class === '' ? null : $class];
     if ($active) {
         Html::addCssClass($options, $this->activePageCssClass);
     }
     if ($disabled) {
         Html::addCssClass($options, $this->disabledPageCssClass);
         return Html::tag('li', Html::tag('span', $label), $options);
     }
     $linkOptions = $this->linkOptions;
     $linkOptions['data-page'] = $page;
     $url = '';
     if ($this->cat) {
         $url .= '/' . GlobalHelper::getCategoryUrlById($this->cat[0]);
     }
     if (array_key_exists('date', Yii::$app->params)) {
         $url .= '/' . Yii::$app->params['date'];
     }
     if ($page != 0) {
         $url .= '/page/' . ($page + 1);
     }
     $url .= '/';
     return Html::tag('li', Html::a($label, $url, $linkOptions), $options);
 }
Esempio n. 2
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create Category', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'options' => ['style' => 'width: 65px; max-width: 65px;'], 'contentOptions' => ['style' => 'width: 65px; max-width: 65px;']], ['attribute' => 'parent_id', 'options' => ['style' => 'width: 75px; max-width: 75px;'], 'contentOptions' => ['style' => 'width: 75px; max-width: 75px;']], ['attribute' => 'name', 'options' => ['style' => 'min-width: 300px;'], 'contentOptions' => ['style' => 'min-width: 300px;']], ['attribute' => 'url', 'format' => 'raw', 'value' => function ($model, $key, $index, $column) {
    $value = $model->url;
    $html = Html::tag('span', Html::encode($value), ['class' => 'label label-blue']);
    return $value === null ? $column->grid->emptyCell : $html;
}], 'category_art', 'add_method', 'postCount', ['class' => BwActionColumn::className(), 'buttons' => ['link' => function ($url, $model) {
    $customurl = Yii::$app->params['frontendBaseUrl'] . GlobalHelper::getCategoryUrlById($model->id) . '/';
    return \yii\helpers\Html::a('<span class="glyphicon glyphicon-link"></span>', $customurl, ['title' => 'Открыть статью', 'target' => '_blank']);
}], 'template' => '{view} {update} {delete} {link}']]]);
?>

</div>
Esempio n. 3
0
<?php

/* @var $this yii\web\View */
use common\components\helpers\GlobalHelper;
?>

<?php 
$allCategories = GlobalHelper::getCategories();
foreach ($categories as $categoryId) {
    // Получаем Url категории по ее ID
    $cat = GlobalHelper::getCategoryUrlById($categoryId);
    $link = '/' . $cat . '/';
    ?>
    <div id="content-item">
        <div id="content-item-top" class="content-item-blue black_link"><span>Подраздел</span> <a href="<?php 
    echo $link;
    ?>
"><?php 
    echo $allCategories[$categoryId]['name'];
    ?>
</a></div>
        <div id="content-item-content">
            <div id="content-small-10" class="img120">
                <?php 
    echo $allCategories[$categoryId]['description'];
    ?>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <?php 
Esempio n. 4
0
 public function getFrontendLink()
 {
     $cat = GlobalHelper::getCategoryUrlById($this->category_id);
     return substr(\Yii::$app->params['frontendBaseUrl'], 0, -1) . \Yii::$app->urlManagerFrontend->createUrl(['post/full', 'cat' => $cat, 'id' => $this->id, 'alt' => $this->url]);
 }
Esempio n. 5
0
 /**
  * Генерация XML карты сайта
  *
  * @return string
  */
 public function generateSitemap()
 {
     $xml_map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
     // Главная страница
     $xml_map .= "\n\t\t<url>\n\t\t\t<loc>" . Yii::$app->params['frontendBaseUrl'] . "</loc>\n\t\t\t<lastmod>" . date("Y-m-d") . "</lastmod>\n\t\t\t<changefreq>daily</changefreq>\n\t\t\t<priority>1.0</priority>\n\t\t</url>";
     // Категории
     $categories = GlobalHelper::getCategories();
     foreach ($categories as $mass) {
         $id = $mass['id'];
         $xml_name = GlobalHelper::getCategoryUrlById($id);
         $xml_date = date("Y-m-d");
         $xml_map .= "\n\t\t<url>\n\t\t\t<loc>" . Yii::$app->params['frontendBaseUrl'] . $xml_name . "/</loc>\n\t\t\t<lastmod>" . $xml_date . "</lastmod>\n\t\t\t<changefreq>daily</changefreq>\n\t\t\t<priority>0.8</priority>\n\t\t</url>";
     }
     // Статьи
     $posts = Post::find()->where(['approve' => '1'])->andWhere(['<=', 'date', date('Y-m-d')])->andWhere(['!=', 'category_art', 1])->orderBy('date')->all();
     //var_dump($posts);
     foreach ($posts as $post) {
         $xml_map .= "\n\t\t<url>\n\t\t\t<loc>" . $post->absoluteLink . "</loc>\n\t\t\t<lastmod>" . date("Y-m-d", strtotime($post->date)) . "</lastmod>\n\t\t\t<changefreq>weekly</changefreq>\n\t\t\t<priority>0.6</priority>\n\t\t</url>";
     }
     $xml_map .= "\n</urlset>";
     return $xml_map;
 }