TYPO3 Extbase:如何对子对象进行排序 [英] TYPO3 Extbase: How to sort child objects

查看:68
本文介绍了TYPO3 Extbase:如何对子对象进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Extbase模型文章和一个1:n关系产品.在条款TCA中,我配置了一个内联字段.我想在我的文章模板中显示所有相关产品.这些由uid整理.我如何才能将子对象的排序更改为字段排序,以便能够对其进行手动排序. (在后端形式中,可以进行排序,仅显示通过字段排序排序的结果是不可能的)

I have an Extbase Model Article and a 1:n Relation Product. In Article TCA i have an inline field configuered. In my Article Template I want to display all related Products. These are oredered by uid. How can i change the ordering of the child objects to the field sorting to be able to manually sort them. ( In the backend form the sorting is possible, only diplaying them sorted by field sorting is not possible )

谢谢, 卢卡斯

推荐答案

在存储库类中,这是我的操作方式:

Here's how I do it, in the repository class:

class ItemRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {

    /**
     * http://www.typo3.net/forum/thematik/zeige/thema/114160/?show=1
     * Returns items of this repository, sorted by sorting
     *
     * @return array An array of objects, empty if no objects found
     * @api
     */

    public function findAll() {
        $orderings = array(
            'sorting' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
        );

        $query = $this->createQuery();
        $query->setOrderings($orderings);

        $query->getQuerySettings()->setRespectSysLanguage(FALSE);
        $query->getQuerySettings()->setSysLanguageUid(0);

        $result = $query->execute();
        return $result;
    }

}

这篇关于TYPO3 Extbase:如何对子对象进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆