Feature #35790

Base Distribution - Work Package #45013: Flexible plugin integration (TODO: Reviews)

allow f:link.action to operate on parent request

Added by Fernando Arconada over 8 years ago. Updated over 7 years ago.

Status:
Resolved
Priority:
Should have
Category:
ViewHelpers
Start date:
2012-04-09
Due date:
% Done:

100%

Estimated time:
Has patch:
No

Description

Original bug description:

if you use f:link.action inside a widget it generates links to the widget actions and not links to other controllers as expected

See below for feature description


Files

widgetLinkWorkaround.patch (437 Bytes) widgetLinkWorkaround.patch Dirty workaround Christoph Gross, 2012-08-23 18:07

Related issues

Related to TYPO3.Fluid - Bug #46135: Undefined index: useParentRequest in AbstractViewHelperClosedKarsten Dambekalns2013-03-08

Actions
#1

Updated by CPS-IT GmbH over 8 years ago

I don't think this is a bug. The viewhelper takes the current controller context which is the widget one's. If you need to link to any other controller (e.g. origin request) you have to assign variables for this and submit them in your template.

$this->view->assign('parentPackage', $this->request->getParentRequest()->getControllerPackageKey());
$this->view->assign('parentSubpackage', $this->request->getParentRequest()->getControllerSubpackageKey());
$this->view->assign('parentController', $this->request->getParentRequest()->getControllerName());
$this->view->assign('parentActionName', $this->request->getParentRequest()->getControllerActionName());

In your Fluid template you can do something like this

<f:link.action action="{parentActionName}" controller="{parentController}" package="{parentPackage}" subpackage="{parentSubpackage}">Link</f:link.action>
#2

Updated by Krzysztof Daniel over 8 years ago

We have this defined as:
<f:link.action package="xxx.Package" controller="Setup" action="close">close</f:link.action>
And still the link is routed internally in the widget.

#3

Updated by Christoph Gross over 8 years ago

Same problem, even with package, subpackage and controller defined the link.action fails to generate the correct link within widgets.

<f:link.action 
    arguments="{account: account}" 
    package="Drinkaccounting" 
    action="show" 
    controller="Account">{account.name}</f:link.action>

http://f3.local/drinkaccounting/controllcenter/index
?--drinkaccounting-viewhelpers-widget-mainnavigationviewhelper[account][__identity]=ec663b7d-04e6-4d9c-8875-eac772f51312
&--drinkaccounting-viewhelpers-widget-mainnavigationviewhelper[@action]=show
&--drinkaccounting-viewhelpers-widget-mainnavigationviewhelper[@controller]=account
&--drinkaccounting-viewhelpers-widget-mainnavigationviewhelper[@package]=drinkaccounting

Also link.action shouldn't generate link to widget actions since there is a viewhelper for that:

<f:uri.widget>
    Generates an URI to another action of the widget.
<f:link.widget>
    Generates a link to another action of the widget.

#4

Updated by Christoph Gross over 8 years ago

I attached a dirty workaround. The problem seems to be with the argumentNamespace and subPackage. Couldn't figure out how to fix.
The workaround might only work for projects without subpackages, but I'm not sure about that.

EDIT: Forgot to say: The Patch is for Flow/Mvc/UriBuilder.php

#5

Updated by Dominique Feyer about 8 years ago

Any news on this issue ?

#6

Updated by Christoph Gross about 8 years ago

Patch does not work anymore in latest Typo3 Flow (1.2 dev-master). This really should be fixed. I currently use the widgets to display a menu with direct access to some objects. That's not an exotic use-case.

Unfortunately I had no success in finding the bug.

#7

Updated by Christoph Gross about 8 years ago

After some digging I found another (dirty) workaround for Flow 1.2:

It seems that the problem occurs when the namespaces are added. This somehow has to do with the nesting of the requests and that's why we get wrong links.

If you change in Typo3/Flow/Mvc/UriBuilder.php the function addNamespaceToArguments to this:

protected function addNamespaceToArguments(array $arguments, \TYPO3\Flow\Mvc\RequestInterface $currentRequest) {
        while (!$currentRequest->isMainRequest()) {
            $argumentNamespace = $currentRequest->getArgumentNamespace();
            if ($argumentNamespace !== '') {

                if(strstr($argumentNamespace, 'viewhelpers-widget')) {
                    $arguments["@subpackage"] = NULL;
                    $arguments = $arguments;
                } else {
                    $arguments = array($argumentNamespace => $arguments);
                }
            }
            $currentRequest = $currentRequest->getParentRequest();
        }

        return $arguments;
    }

It works again. This will have some sideeffects if you use links within your widget I think.

#8

Updated by Christoph Gross almost 8 years ago

But still present in latest Flow version (2.0)

#9

Updated by Marc Neuhaus almost 8 years ago

This Behavior is actually no bug, it's by Design.

Widgets are executed in an SubRequest and because of this the URI Builder generates the Link inside that Request.
Currently there is no default way to generate links for another Request.

I'll raise this issue with Sebastian.

#10

Updated by Christoph Gross almost 8 years ago

Ah, that explains the behavior, would be nice to somehow circumvent it since we have a fluid tag for widget links and one for actions:

<f:uri.widget> / <f:link.widget>
    Generates an URI / link to another action of the widget.
<f:link.action> / <f:uri.action>
    Generates a link / URI to another action.

#11

Updated by Bastian Waidelich almost 8 years ago

  • Tracker changed from Bug to Feature
  • Subject changed from f:link.action inside a widget fails to allow f:link.action to operate on parent request
  • Category set to ViewHelpers
  • Status changed from New to Accepted
  • Priority changed from Must have to Should have

Add argument useParentRequest (boolean) to relevant link & uri ViewHelpers

#12

Updated by Bastian Waidelich almost 8 years ago

  • Assignee set to Marc Neuhaus
#13

Updated by Gerrit Code Review almost 8 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18045

#14

Updated by Gerrit Code Review almost 8 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18045

#15

Updated by Gerrit Code Review almost 8 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18045

#16

Updated by Gerrit Code Review almost 8 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18045

#17

Updated by Gerrit Code Review almost 8 years ago

Patch set 5 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18045

#18

Updated by Gerrit Code Review almost 8 years ago

Patch set 6 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18045

#19

Updated by Gerrit Code Review almost 8 years ago

Patch set 7 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18045

#20

Updated by Gerrit Code Review almost 8 years ago

Patch set 8 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18045

#21

Updated by Anonymous over 7 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#22

Updated by Marc Neuhaus over 7 years ago

  • Parent task set to #45013
#23

Updated by Christopher Hlubek over 7 years ago

  • Status changed from Resolved to Needs Feedback
  • Assignee changed from Marc Neuhaus to Karsten Dambekalns

Since this is a blocker to use widgets in other ways than just a pagebrowser with widget-only links, I think we need that also in 2.0. Also since this is not the Flow package and not a big feature it shouldn't be a problem.

#24

Updated by Gerrit Code Review over 7 years ago

  • Status changed from Needs Feedback to Under Review

Patch set 1 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/20544

#25

Updated by Bastian Waidelich over 7 years ago

  • Target version set to 2.0
#26

Updated by Anonymous over 7 years ago

  • Status changed from Under Review to Resolved

Also available in: Atom PDF