【发布时间】:2020-11-12 15:46:09
【问题描述】:
我想检查单词 $filterwords 是否出现在其中一个对象中并在我的小部件过滤器中过滤它们。
结构如下: 类博客有 n 个功能。并且功能有一个名称。
例如:
Blog1
-Feature1
--Name "Fast"
-Feature2
--Name "Beautiful"
Blog2
-Feature1
--Name "Fast"
Blog3
-Feature2
--Name "Beautiful"
现在我想要所有具有“快速”属性的博客。
在 List.html 中,我实际上想这样调用我的过滤器:
<example:widget.myfilter objects="{blogs}" as="filteredblogs" property="features.name">
但这是不可能的,因为特征是 n 个对象。 “关系匹配中使用的不支持或不存在的属性名称“name”。”
因此它只能这样工作:
<example:widget.myfilter objects="{blogs}" as="filteredblogs" property="features">
所以在我的小部件过滤器控制器中,我得到这样的属性:
/**
* @var QueryResultInterface
*/
protected $objects;
public function initializeAction()
{
$this->objects = $this->widgetConfiguration['objects'];
$this->property = $this->widgetConfiguration['property'];
$this->as = $this->widgetConfiguration['as'];
}
/**
* @param string $filterword
*/
public function indexAction(string $filterword = ""): void
{
$query = $this->objects->getQuery();
$query->matching($query->contains($this->property, $filterword));
...
现在的问题是“包含”查询不起作用,因为他必须检查属性“功能”->“名称”。但它不会将“Feature.name”作为属性传递,而只会传递“特征”。您必须以某种方式告诉“包含”它应该检查“名称”。
【问题讨论】:
标签: filter widget typo3 extbase fluid