Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TYPO3 Extbase: setDefaultOrderings in Controller

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

like image 997
Ralf Avatar asked Feb 09 '14 14:02

Ralf


2 Answers

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);
    }
}
like image 192
Ghanshyam Gohel Avatar answered Oct 11 '22 05:10

Ghanshyam Gohel


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

=)

like image 38
Daniel Avatar answered Oct 11 '22 05:10

Daniel