开发者

Exclude items from a query based on their tags with Symfony/diem and doctrine

In Diem CMS I would like to do a conditional statement that would exclude some articles based on the tag model

Diem documentation gives the following for conditional queries (http://diem-project.org/diem-5-1/doc/en/reference-book/list-widgets)

$query = $this->getListQuery('post')
->addWhere('post.name LIKE ?', '%symfony%');  

Is there a way to exclude some post according to the tags it has?

Here is my new query which seems better (to me at least) but it is still not working.

public function executeList()
{
    $query = $this-&g开发者_JAVA百科t;getListQuery();
    $query->leftJoin('DmTag');
    $query->addWhere('DmTag.name NOT LIKE ?', '%Fichets%');
    $this->articlePager = $this->getPager($query);
    $this->articlePager->setOption('ajax', true);
  }

The Diem blog is done according to the Diem tutorial and I use the standard (out of the box so to say) Diem Tag plugin. I did not modify the model nor the name of the Table.


This is the working query:

public function executeList()
{
    $query = $this->getListQuery('a'); // add an alias
    $query->leftJoin('a.Tags t'); // Join on the DmTag table
    $query->addWhere('t.name NOT LIKE ?', '%Fichets%'); //Exclude the articles with a certain tag
    $this->articlePager = $this->getPager($query);
    $this->articlePager->setOption('ajax', true);
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜