Exemplo n.º 1
0
 /**
  * @param int|null    $id        ID of post-type.
  * @param string|null $post_type Slug of post-type.
  *
  * @return string
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionIndex($id = null, $post_type = null)
 {
     $render = 'index';
     //var_dump($id, $post_type); exit;
     if ($id) {
         $postType = $this->findPostType($id);
     } else {
         if ($post_type) {
             $postType = $this->findPostTypeBySlug($post_type);
         } else {
             throw new NotFoundHttpException(Yii::t('content', 'The requested page does not exist.'));
         }
     }
     $query = $postType->getPosts()->andWhere(['post_status' => 'publish'])->orderBy(['id' => SORT_DESC]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => Option::get('posts_per_page')]);
     $query->offset($pages->offset)->limit($pages->limit);
     $posts = $query->all();
     if ($posts) {
         if (is_file($this->view->theme->basePath . '/post/index-' . $postType->post_type_slug . '.php')) {
             $render = 'index-' . $postType->post_type_slug . '.php';
         }
         return $this->render($render, ['postType' => $postType, 'posts' => $posts, 'pages' => $pages]);
     } else {
         throw new NotFoundHttpException(Yii::t('content', 'The requested page does not exist.'));
     }
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'rules' => [['actions' => ['login', 'request-password-reset', 'reset-password', 'forbidden', 'not-found', 'terms'], 'allow' => true], ['actions' => ['logout', 'index', 'error'], 'allow' => true, 'roles' => ['@']], ['actions' => ['signup'], 'allow' => true, 'matchCallback' => function ($rule, $action) {
         return Option::get('allow_signup') && Yii::$app->user->isGuest;
     }]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['logout' => ['post']]]];
 }
Exemplo n.º 3
0
            <div class="col-xs-4">
                <?php 
echo Html::submitButton('Signin', ['class' => 'btn btn-primary btn-block btn-flat', 'name' => 'signin-button']);
?>
            </div>
        </div>
        <?php 
ActiveForm::end();
?>

        <?php 
echo Html::a(Yii::t('content', 'Reset Password'), ['/site/request-password-reset']);
?>

        <br/>

        <?php 
echo Option::get('allow_signup') ? Html::a(Yii::t('content', 'Register a new membership'), ['/site/signup']) : "";
?>

    </div>

    <br/>

    <?php 
echo Html::a('<i class="fa fa-home"></i> ' . Yii::t('content', 'Back to {sitetitle}', ['sitetitle' => Option::get('sitetitle')]), Yii::$app->urlManagerFront->createUrl(['/site/index']), ['class' => 'btn btn-block btn-success']);
?>

</div>

Exemplo n.º 4
0
 /**
  * Search post by title and content
  *
  * @param $s
  *
  * @return string
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionSearch($s)
 {
     $query = Post::find()->orWhere(['LIKE', 'post_title', $s])->orWhere(['LIKE', 'post_content', $s])->andWhere(['post_status' => 'publish'])->orderBy(['id' => SORT_DESC]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => Option::get('posts_per_page')]);
     $query->offset($pages->offset)->limit($pages->limit);
     $posts = $query->all();
     if ($posts) {
         return $this->render('/site/search', ['posts' => $posts, 'pages' => $pages, 's' => $s]);
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }