[TYPO3-mvc] How do you get the "next" record when on a detail view?
Claus Due
claus at wildside.dk
Sat Jan 28 15:52:50 CET 2012
Hi again,
Forgot to mention that you may need to have {allCards} be an array of uids of records, and then use this:
<f:link action="show" arguments="{card: '{fed:next(haystack: allCards, needle: card.uid)}'">Next card</f:link>
Since I am not sure wether the string treatment of '{fed:next}', which is necessary to trigger the viewhelper call instead of a parse error, will return a proper value to use as a URL argument for your controller.
You would try the first example first, and if that doesn't work move on to the above approach.
--
Cheers,
Claus
http://fedext.net
On Jan 28, 2012, at 3:44 PM, Claus Due wrote:
> Hi Stephen,
>
> I have a suggestion. If what you are trying to do is to make some sort of navigation (almost page browser but with one item per page and only previous/next links) then this might be useful:
>
> http://fedext.net/fed-viewhelpers/loops-conditions/next/
> http://fedext.net/fed-viewhelpers/loops-conditions/previous/
>
> What you would need to do is to always assign the "master list" of Cards (for example a $repository->findAll() which is always in the same order), then use that template variable as the "haystack" parameter and the currently viewed card as the "needle" parameter.
>
> This way you can link to the next Card in your result set:
>
> <f:link action="show" arguments="{card: '{fed:next(haystack: allCards, needle: card)}'">Next card</f:link>
>
> The same exact thing goes for the fed:previous viewhelper.
>
> Hope this helps :)
>
> --
> Cheers,
> Claus
> http://fedext.net
>
> On Jan 28, 2012, at 11:30 AM, Stephen Bungert wrote:
>
>> Thanks, it works, i can ouput the next record in my template
>>
>> {next.title} show the correct title, so I know it has found the correct record.
>>
>> But if I try and debug the next record in fluid or in my controller the output from typo3 is a blank page.
>>
>> Can you debug your next item in your fluid template ok?
>>
>> "Alexander Dick" <typo3 at dick.at> schrieb im Newsbeitrag news:mailman.1.1327739758.21075.typo3-project-typo3v4mvc at lists.typo3.org...
>>>
>>> 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.
>>
>> _______________________________________________
>> TYPO3-project-typo3v4mvc mailing list
>> TYPO3-project-typo3v4mvc at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>
> _______________________________________________
> 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