TYPO3 Extbase: setDefaultOrderings in Controller
Asked Answered
S

2

7

I have an extension (extbase/fluid) with an main object "Etikett" with a relation to a child object "Land". I want to order my output, so I'm using the setDefaultOrderings method in my Etikett controller, but I got no results, why?

$this->etikettRepository->setDefaultOrderings(array('land.laendername' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING));
$etiketts = $this->etikettRepository->findAll();

Relation

Scarlettscarp answered 9/2, 2014 at 14:35 Comment(6)
Same empty result with: $query = $this->createQuery(); $query->equals('land', $land); $query->setOrderings(array('region.regionenname' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING));Scarlettscarp
info: land has a region with property regionennameScarlettscarp
So you dont get anything out of your repository? Or is the ordering not working? If its the first, make sure you set the storage pid in your plugins Typoscript or disable the respectStoragePid in your repository.Intellectualize
Yeahaa thank you Daniel, it was the first, but it was a little bit more complex, because I have a seperate systemfolder for my regions and added only the folder with the labels! You mady my day! ;)Scarlettscarp
Glad to help. I'll provide it as answer so you can accept it to made the question marked as answered.Intellectualize
Yes sure! ;) I would like mark it as useful, but first I need 15 reputation :DScarlettscarp
I
5

Make sure you set the storage pid in your plugins Typoscript or disable the respectStoragePid in your repository.

=)

Intellectualize answered 9/2, 2014 at 20:8 Comment(0)
R
7

You can set default order in your Repository.

class etikettRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
    /*
     * Default ordering for all queries created by this repository
     */
    protected $defaultOrderings = array(
        'your_field_name' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
    );

    public function findAll(){
        //Your query
        $query->getQuerySettings()->setRespectStoragePage(FALSE);
    }
}
Represent answered 5/5, 2014 at 6:12 Comment(0)
I
5

Make sure you set the storage pid in your plugins Typoscript or disable the respectStoragePid in your repository.

=)

Intellectualize answered 9/2, 2014 at 20:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.