[TYPO3-mvc] extbase SetOrderings doesn't work

Johannes C. Schulz - EnzephaloN IT-Solutions info at enzephalon.de
Wed Jan 26 16:56:42 CET 2011


Hello again to all!

After a lot of coding, I've no idea why the sorting doesn't work. Like you
say the code is fine and the generated SQL-statement is fine to. But the
output on frontend still is sorted by 'uid' instead of 'name' or
'dateadded'. And of curse the ASC or DESC ordering doesn't work.

Again my function from the Repository:
	/**
	 * Shows all bands of a year
	 *
	 * @param int $year The year to show
	 * @param string $orderBy ASC or DESC by flexform?
	 * @param string $orderDirection By name or by date?
	 * @return array The Bands
               */
      public function listOfBandsInYearBy($year,$orderDirection,$orderBy){
            $orderings = array($orderBy => $orderDirection ==
'ORDER_ASCENDING' ? 
 
Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING : 
 
Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING);
            $query = $this->createQuery();
            return $query -> matching($query->equals('year',intval($year) )
) 
                                -> setOrderings($orderings) 
                                -> execute();
      }

Do you know problems with cooluri or other settings due orderingproblems?
Is there an undeletable cache (by "clear all caches") which I can delete?
Btw: For the page I installed the plugin "Cache" is disabled. Maybe I have
to disable Cache for the extension or extbase?

Kindly regards
Johannes

Hi!


Hi,

> public function listOfBandsInYearBy($year,$sortby,$sorttype){
>        $frage = $this->createQuery();
>        $frage->matching($frage->equals('year',$year) );
>        if($sortby=='ORDER_ASCENDING'){
>                  $frage->setOrderings(array($sorttype =>
> Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING) );
>        }
>        else{
>                  $frage->setOrderings(array($sorttype =>
> Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING) );
>        }
>        return $frage->execute();
> }
>

aeh? for me it looks as if you mismatched $sorttype and $sortby.
At least from the naming i would consinder sortby containing a field 
namen while sorttype should indicate ascending or descending.

Cheers,
Nikolas

No, of curse the names are badly choosen, but the values of the variables
are right.

@Franz
With use of DevLog I "extracted" the SQL-Statement and tested it with
phpmyadmin. There the ordering was correct.

Pagination isn't planned for this extension.

Best regards
Johannes

_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc




More information about the TYPO3-project-typo3v4mvc mailing list