简体   繁体   English

根据使用 Symfony/diem 和 doctrine 的标签从查询中排除项目

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

In DIEM CMF I would like to do a conditional statement that would exclude some articles based on the tag model在 DIEM CMF 中,我想做一个条件语句,排除一些基于标签 model 的文章

Diem documentation gives the following for conditional queries (http://diem-project.org/diem-5-1/doc/en/reference-book/list-widgets) Diem 文档为条件查询提供了以下内容 (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?有没有办法根据它的标签排除一些帖子?

Thank you谢谢

Update更新

Here is my new query which seems better (to me at least) but it is still not working.这是我的新查询,它看起来更好(至少对我来说),但它仍然无法正常工作。

public function executeList()
{
    $query = $this->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. Diem 博客是根据 Diem 教程完成的,我使用标准(可以说是开箱即用)Diem Tag 插件。 I did not modify the model nor the name of the Table.我没有修改 model 也没有修改表的名称。

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);
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM