Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在TYPO3中为系统类别编写查询_Php_Typo3_Categories_Extbase - Fatal编程技术网

Php 如何在TYPO3中为系统类别编写查询

Php 如何在TYPO3中为系统类别编写查询,php,typo3,categories,extbase,Php,Typo3,Categories,Extbase,我已经用extbase/fluid编写了一个小扩展,现在我在存储库中遇到了一个小问题 使用my extension,您可以创建使用system_类别进行分类的项目ST(类似于每个新闻扩展)。 我想做的是在第x页显示所有类别为x的项目,在第y页显示所有类别为y的项目 我知道我必须在我的itemRepository.php中编写查询,但我无法让它工作,因此下面是我的存储库代码: public function findSearchForm($limit) { $query = $this

我已经用extbase/fluid编写了一个小扩展,现在我在存储库中遇到了一个小问题

使用my extension,您可以创建使用system_类别进行分类的项目ST(类似于每个新闻扩展)。 我想做的是在第x页显示所有类别为x的项目,在第y页显示所有类别为y的项目

我知道我必须在我的itemRepository.php中编写查询,但我无法让它工作,因此下面是我的存储库代码:

 public function findSearchForm($limit)
{

    $query = $this->createQuery();

    $query->getQuerySettings()->setLanguageUid($GLOBALS["TSFE"]->tmpl->setup['config.']['sys_language_uid']);
    $query->matching(
        $query->like('title','%'.$search.'%')
    );

   # $query->setOrderings(array('title' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING));


    return $query->execute();
}
我尝试在“query->like”之后扩展查询,即使使用这样的语句

$query->statement("SELECT * FROM sys_category_record_mm WHERE uid_local = '11'")

首先:您是如何对记录进行分类的?它在后端正常工作吗

当您的TCA正确配置为类别使用时,您可以使用公共存储库方法来过滤结果。但是你必须把条件和你的“标题”结合起来——条件使用和

试着这样做:

public function findSearchForm($limit)
{

    $query = $this->createQuery();
    $constraints = array();
    $yourCategory = 11;

    // Your $search-variable seems to be undefined?
    //$constraints[] = $query->like('title','%'.$search.'%');
    $constraints[] = $query->contains('categories', $yourCategory);

    $query->matching(
        $query->logicalAnd($constraints)
    );

    // I think you dont need this...
    $query->getQuerySettings()->setLanguageUid($GLOBALS["TSFE"]->tmpl->setup['config.']['sys_language_uid']);

    return $query->execute();

}

感谢您分享此解决方案。对我来说真是太好了!