[TYPO3-mvc] How do you get the "next" record when on a detail view?

Alexander Dick typo3 at dick.at
Sat Jan 28 09:35:59 CET 2012


Hi,

I made it this way:

     /**
      * Finds the previous of the given item
      *
      * @param Tx_Xxx_Domain_Model_Card $card The reference card
      * @return Tx_hochzeitseinladungen_Domain_Model_Card
      */
     public function findPrevious(Tx_Xxx_Domain_Model_Card $card) {
         $query = $this->createQuery();
         $cards = $query->matching($query->lessThan('uid', 
$card->getUid()))
             ->setLimit(1)
             ->execute();
         return (count($cards) == 0) ? NULL : $cards->getFirst();
     }

     /**
      * Finds the card next to the given card
      *
      * @param Tx_Xxx_Domain_Model_Card $card The reference card
      * @return Tx_Xxx_Domain_Model_Card
      */
     public function findNext(Tx_Xxx_Domain_Model_Card $card) {
         $query = $this->createQuery();
         $cards = $query->matching($query->greaterThan('uid', 
$card->getUid()))
             ->setLimit(1)
             ->execute();
         return (count($cards) == 0) ? NULL : $cards->getFirst();
     }

HTH
kind regards
Alex

Am 27.01.2012 20:47, schrieb Stephen Bungert:
> I have a function in my repository:
>
> /**
> * Finds the single view's item's next item
> *
> * @param integer $uid The uid of the current single item.
> * @return mixed An item
> */
> public function findNext($uid) {
> $query = $this->createQuery();
> $query->matching($query->greaterThan('uid', $uid));
> return $query->execute();
> }
>
> That I call in my detail action in my controller.
>
> $uid is the uid of the detail record, but trying to debug the return of
> this function causes TYPO3 to not output anything.
>
> I tried looking at other extbase extensions like news and blogexample
> but I couldn't see any examples of how to get next records.
>
>
> Thanks for any help.
>
> Stephen.


More information about the TYPO3-project-typo3v4mvc mailing list