Commit bbabb84a authored by andre's avatar andre

Merge branch 'blog-hashtag-filtr'

parents 81e3acc9 2dd3395f
......@@ -16,6 +16,8 @@ class UrlManager extends \yii\web\UrlManager {
$rules['<page:('.$page->url.')>'] = 'content/page/view';
}
$request->url = rtrim($request->url, '/');
$this->addRules($rules, false);
return parent::parseRequest($request);
......
......@@ -62,41 +62,8 @@ class PostController extends BaseController
$tag = $this->getCookie();
// if(count($tag))
// {
//
// '
// SELECT * FROM `posts`
// WHERE `posts`.id IN (
// SELECT `post_id`
// FROM `posts_tags_assign`
// WHERE `tag_id` IN (1,2)
// GROUP BY post_id HAVING COUNT(post_id)=2
// )
// ';
//
// $subQuery = PostTagAssign::find();
// $subQuery->where(["tag_id" => $tag]);
// $subQuery->groupBy('post_id');
// $subQuery->having(['count(post_id)' => count($tag)]);
//
// $query = Post::find()->where('posts.active=1')->limit(Post::PAGE_SIZE)->orderBy(Post::tableName().'.created_at DESC');
// $query->an
//// $query->andWhere()
//
// }
// else
// {
// $query = Post::find()->where('posts.active=1')->limit(Post::PAGE_SIZE)->orderBy(Post::tableName().'.created_at DESC');
// }
if(count($tag))
{
// $searchPost = new SearchPost();
// $query = $searchPost->findByTags($tag);
$query = Post::find()->where(['active' => 1])->orderBy(Post::tableName().'.created_at DESC');
$query = $query->joinWith('postTagAssigns')->andWhere([PostTagAssign::tableName().'.tag_id' => $tag]);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment