3

When using Extbase's "show" action:

<f:link.action action="show" arguments="{event : event}">

I would like to look up said event by a special column ('customID').

The actual TYPO3-uid should NOT appear in the URL (with or without RealURL).

The reason is that the data has been imported, and the "real" uid is 'customId'.

There's always @biesior's approach using f:link.page https://stackoverflow.com/a/26145125/160968 – but I thought I'd try it with the official way.

(how) is it possible to do that in extbase/fluid?

Community
  • 1
  • 1
Urs
  • 4,984
  • 7
  • 54
  • 116
  • 1
    My answer there is rather for avoiding Controller and Action parts in the URL, for just declaring the type of param in show action (other than model;s object) @lorenz has better solution. – biesior Apr 04 '16 at 20:27

2 Answers2

3

This is possible. Let's assume your model Event has a property customId. So you generate your link like this:

<f:link.action action="show" arguments="{event : event.customId}">

The link generated will have a queryString like this:

?tx_myext[event]=9999

The showAction generated by the Extension Builder expects that the UID of the event is passed. The PropertyMapper then fetches the object automatically and assigns it to the view:

/**
 * action show
 *
 * @param \Your\Extension\Domain\Model\Event $event
 * @return void
 */
public function showAction(\Your\Extension\Domain\Model\Event $event) {
    $this->view->assign('event', $event);
}

But in your case you cannot fetch the object by UID because you passed the customId. So you need to fetch the object yourself:

/**
 * action show
 *
 * @param integer $event
 * @return void
 */
public function showAction($event) {
    $event = $this->eventRepository->findOneByCustomId($event);
    $this->view->assign('event', $event);
}

The annotation @param integer $event tells TYPO3 that the parameter is "just" an integer. You then call the magic method findOneByCustomId from your eventRepository. findOne indicates that you want exactly one Event object back (and not a QueryResult), while the ByCustomId that queries an existing property of your Event model.

lorenz
  • 4,538
  • 1
  • 27
  • 45
  • now I'm torn again. as this solution works as well as biesor's "clean-url" solution - what's the argument to stick with f:link.action instead of f:link.page again (if I only have a show and list action)? – Urs Apr 05 '16 at 18:12
  • This has nothing to do with link.action vs. link.page. It just shows a way of requesting an object for a single view without using or exposing the uid. You still may go with the "clean URL" approach. – lorenz Apr 06 '16 at 19:15
  • Yes, I was just not sure which was better. I guess it's only relevant if you have more than list/show actions. Thanks! – Urs Apr 06 '16 at 21:36
0

Why not use realUrl with lookUpTable? See here: https://wiki.typo3.org/Realurl/manual#-.3ElookUpTable

sven
  • 609
  • 5
  • 14