Example #1
0
 /**
  * Registers page content when big performs a search.
  * See [[bigbrush\big\core\Big::search()]] for more information about the search process.
  *
  * @param bigbrush\big\core\SearchEvent $event the event being triggered
  */
 public static function onSearch($event)
 {
     $query = Page::find()->select(['id', 'title', 'category_id', 'alias', 'intro_content', 'created_at'])->orderBy('title')->asArray();
     // adjust query if $event->value is not empty. Then a search for a specific value is being made.
     if (!empty($event->value)) {
         $query->orWhere(['like', 'title', $event->value]);
         $query->orWhere(['like', 'content', $event->value]);
     }
     $items = $query->all();
     foreach ($items as $item) {
         $event->addItem(['title' => $item['title'], 'route' => Route::page($item), 'text' => $item['intro_content'], 'date' => $item['created_at'], 'section' => Yii::t('cms', 'Pages')]);
     }
     // pages categories
     foreach (Yii::$app->big->categoryManager->getItems('pages') as $item) {
         // $event->value is a value being searched for. If set then only include the category when its title matches
         // the search string
         if (!empty($event->value) && strpos($item->title, $event->value) === false) {
             continue;
         }
         // match found so add it in the $event
         $event->addItem(['title' => str_repeat('- ', $item->depth - 1) . $item->title, 'route' => Route::category($item), 'text' => $item->content, 'date' => $item->created_at, 'section' => Yii::t('cms', 'Pages categories')]);
     }
 }
Example #2
0
$title = $model->id ? Yii::t('cms', 'Edit {0}', $type) : Yii::t('cms', 'Create {0}', $type);
$this->title = $title;
if (!$model->getIsNewRecord()) {
    $title .= ' <span class="small">[ ' . $model->title . ' ]</span>';
}
$toolbar = Yii::$app->toolbar;
?>

<?php 
$form = ActiveForm::begin();
?>
    
    <?php 
$toolbar->save()->saveStay()->back();
if (!$model->getIsNewRecord()) {
    $url = Yii::$app->getUrlManager()->createUrlFrontend(Route::category($model));
    $toolbar->addButton(Html::a($toolbar->createText('eye', Yii::t('cms', 'Go to category')), $url, $toolbar->createButtonOptions(['target' => '_blank'])));
}
?>

    <h1><?php 
echo $title;
?>
</h1>
    
    <div class="row">
        <div class="col-md-12">
            <?php 
echo Tabs::widget(['items' => [['label' => Yii::t('cms', 'Category'), 'content' => $this->render('_tab_category', ['form' => $form, 'model' => $model, 'parents' => $parents, 'templates' => $templates])], ['label' => Yii::t('cms', 'Publishing'), 'content' => $this->render('_tab_publishing', ['form' => $form, 'model' => $model])], ['label' => Yii::t('cms', 'Images'), 'content' => $this->render('_tab_images', ['form' => $form, 'model' => $model])], ['label' => Yii::t('cms', 'Seo'), 'content' => $this->render('_tab_seo', ['form' => $form, 'model' => $model])], ['label' => Yii::t('cms', 'Info'), 'content' => $this->render('_tab_info', ['form' => $form, 'model' => $model])]]]);
?>
        </div>