I have started a extension under TYPO3 6.2, and migrated this to TYPO3 7. Now it seems, that all links to Controller/Action combinations are broken.
In my TypoScript I have set:
plugin.tx_extensionname.view.pluginNamespace = tx_extensioname
In ext_tables.php I have set:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'Pi1',
'Controller1: DoSomeLogic1'
);
....
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'Pi12',
'Controller12: DoSomeLogic12'
);
In ext_localconf.php the plugins get configured:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'MRU.' . $_EXTKEY,
'Pi2',
array(
'Basket' => 'list, add, remove, address, setDeliveryCountryJson',
'Order' => 'directorder, savedirectorder, accountorder, loginorder, saveloginorder, saveaccountorder, overview, doOrder, paymentSuccess, paymentFailure, paymentNotification, paymentCancel',
'Payment' => 'index'
),
// non-cacheable actions
array(
'Basket' => 'list, add, remove, address, setDeliveryCountryJson',
'Order' => 'directorder, savedirectorder, accountorder, loginorder, saveloginorder, saveaccountorder, overview, doOrder, paymentSuccess, paymentFailure, paymentNotification, paymentCancel',
'Payment' => 'index'
)
);
On a page (id 42) I have placed the plugin Pi2. The Basket Controller is shown with list action. All fine. The URL is like this:
http://www.example.com/index.php?id=42
If I add the namespaced Controller Parameter, like this
http://www.example.com/index.php?id=42&tx_extensionname[controller]=Basket
I get instantly the
#1313855173: The controller "Basket" is not allowed by this plugin. Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.
Exception. If I add the pluginname to the URI like this
http://www.example.com/index.php?id=42&tx_extensionname_pi2[controller]=Basket
no expecption is thrown. But if I call a action like this
http://www.example.com/index.php?id=42&tx_extensionname_pi2[controller]=Basket&tx_extensionname_pi2[action]=add
this action gets never called. The Controller with it's first action is called.
I did the update some weeks ago, it is only a dev system, but today I cleared all caches and the error occours. Have I missed something with plugin combined namespaces and the registration/configuration/linking of it?
Ok, it seems that this resolve my issue:
plugin.tx_extensionname.mvc.callDefaultActionIfActionCantBeResolved = 1
With callDefaultActionIfActionCantBeResolved = 0 or missing the above, i get the Not Allowed Exception. Settings this to 1 the Controller and Action gets called.
Related
I've got a big TYPO3 page with a self coded plugin. Now I want that all stuff which is done in this extension isn't cached.
For example all the inputs were cached and when I reload the page all fields are prefilled
what can I do?
If it's a extbase extension you write in ext_tables.php
<?php
defined('TYPO3_MODE') or die();
// Plugin
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Vendor.' . $_EXTKEY,
'Pluginname',
array(
'Plugin' => 'controller1',
),
// non-cacheable actions
array(
'Plugin' => 'controller1',
)
);
Or disable cache in Page > Setting > Behaviour > Cache > Disable
Inside my extbase extension I have an appointment model and users can write feedback to how the appointment was.
So I created a feedback model with different fields.
Now what should I implement for when the user clicks on the "Create Feedback" button?
So far I got this, but it's not working:
<f:link.action action="edit" controller="Feedback" arguments="{appointment:appointment}">
I get the the error:
Argument 1 passed to
...Controller\FeedbackController::newAction() must be an instance of
...\Model\Appointment, none given
FeedbackController:
/**
* action new
* #param ...\Domain\Model\Appointment $appointment
* #return void
*/
public function newAction(...\Domain\Model\Appointment $appointment) {
$this->view->assign('appointment', $appointment);
}
Why do I get this error? (the appointment object was definitely there, I debugged it)
I figure it must've something to do with the switch from AppointmentController to FeedbackController.
What's the best way to implement this?
You need the pluginName parameter in your link generation if you use different plugins.
<f:link.action action="edit" controller="Feedback" pluginName="your_plugin" arguments="{appointment:appointment}">
When generating a link TYPO3 prepends the "namespace" of the argument to the link like this: tx_myplugin[action]=new. Make sure, that the pluginName is the same one you defined in ext_localconf.php. In this case the pluginName would be your_plugin.
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Vendor.' . $_EXTKEY,
'your_plugin',
array(
'Feedback' => 'new',
),
// non-cacheable actions
array(
'Feedback' => '',
)
);
Check the plugin-controller-action array in your ext_localconf.php and post it. Maybe there is something wrong.
If you get this error :
Argument 1 passed to ...Controller\FeedbackController::newAction()
must be an instance of ...\Model\Appointment, none given
it's because you give the controler a NULL object and taht's not allowed with your controller.
To avoid this error, you could allow NULL object in your controller :
/**
* action new
* #param ...\Domain\Model\Appointment $appointment
* #return void
*/
public function newAction(...\Domain\Model\Appointment $appointment=NULL) {
$this->view->assign('appointment', $appointment);
}
this is weird because in your link, you call an action 'edit' and you have an error in 'newAction' controller instead of 'editAction' controller, you should have the 'edit' action allowed for your plugin (cachable or not) :
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Vendor.' . $_EXTKEY,
'your_plugin',
array(
'Feedback' => 'edit',
),
// non-cacheable actions
array(
'Feedback' => 'edit',
)
);
and as Natalia wrote add the plugin name if the action you want to call belongs to another plugin.
<f:link.action action="edit" controller="Feedback" pluginName="your_plugin" arguments="{appointment:appointment}">
Florian
When I try to add the wizard named wizard_geo_selector in TCA ,there arised an error "module not registered".Please tell me how to register the wizard properly in the TCA.?
In TYPO3 Version 7.6 new wizards are added like this:
Inside your extension create the directory Configuration/Backend/
In the new directory create a file Routes.php, it will be found automatically, no mentioning in ext_localconf.php or ext_tables.php is required. If you still need Ajax you can add the file AjaxRoutes.php in the same folder.
Content for Routes.php:
return array(
'my_wizard_element' => array(
'path' => '/wizard/tx_geoselecotor/geo_selector_wizard',
'target' => \Path\To\your\class\WizardGeoSelector::class . '::WizardAction'
),
);
Content for AjaxRoutes.php
<?php
/**
* Definitions for routes provided by EXT:backend
* Contains all AJAX-based routes for entry points
*
* Currently the "access" property is only used so no token creation + validation is made
* but will be extended further.
*/
return array('my_ajax_element' => array(
'path' => 'tx_geoselecotor/my_ajax_route',
'target' => \Path\To\your\class\MyAjaxController::class .'::myAjaxFunction'
));
If you're unsure about the notation you can compare with existing entries in the Global Variables in the Backend:
Navigate to System -> Configuration -> Backend Routes
The route of the paths is handled different, for Ajax it's always "ajax" prepended, so you've never to add it to the path, else it's twice in the route. For the common route there is no change concerning the defined string.
Now the wizard can be used and even it never has to be defined in ext_tables.php it has to be mentioned there from any table-field in the configuration-area (module[name]):
'table_field_for_wizard' => array(
'label' => 'LLL:EXT:my_extension/Resources/Private/Language/locallang.xml:table_name.tx_myextension_wizard',
'config' => array (
'type' => 'user',
'userFunc' => 'Path/to/class/without/wizard->renderForm',
'wizards' => array(
'my_wizard' => array(
'type' => 'popup',
'title' => 'MyTitle',
'JSopenParams' => 'height=700,width=780,status=0,menubar=0,scrollbars=1',
'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/img/link_popup.gif',
'module' => array(
'name' => 'my_wizard_element',
'urlParameters' => array(
'mode' => 'wizard',
'ajax' => '0',
'any' => '... parameters you need'
),
),
),
'_VALIGN' => 'middle',
'_PADDING' => '4',
),
# Optional
#'softref'=>'something',
),
),
In the userFunc Path/to/class/without/wizard->renderForm you've to create a button which is linking to the wizard and onClick the wizard will open with the route you defined in Routes.php and the optional urlParameters.
Currently I never found this whole item explained in the core-documentation.
Edit:
Details about routing can be found here: Routing
The rendering process can be found here: Rendering / NodeFactory
You should probably read also the outer context of the linked paragraph.
Edit 2:
An example extension can be found here, some things never work 100% but the wizard is working. The extension is for TYPO3 Version 7:
https://github.com/DavidBruchmann/imagemap_wizard
Ricky's answer doesn't really work anymore, since addModulePath ist deprecated since version 7.
Also, just registering the module like this still give's you said error.
The only thing that keeps the wizard going again is this:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule('wizard','pbsurvey_answers',"",\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY).'wizard/');
But when you add this, the module appears as a new point in your TYPO3 backend.
IN TCA add the wizard like follows:
'module' => array(
'name' => 'wizard_geo_selector',
),
In ext_tables.php register the wizard.
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
'wizard_geo_selector',
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Modules/Wizards/Yourwizardname/'
);
Keep in mind this is deprecated since Typo3 7 and removed in Typo3 8.So you can use this method upto Typo3 7.For Typo3 8 do use the method specified by David below.
I have a ZF app with several modules as this: ( as usual )
root\
\application\
\default
\items
\me
\controllers
\views
The application uses the default routing like /module/controller/action;
What I want is this: if no match has been found for the default Zend Routing (no action / controller / module has been found ) then route to a desired path with the url endpoint spitted into parameters.
For example:
mydomain.lh/me -> will match the module me, controller index, action index ( as default )
mydomain.lh/my_category_name -> will match the module items, controller index, action index, params: category => my_category_name -> using the desired path route
no my_category_name module exists to match against
I have tried with this, into bootstrap.php:
public function _initRoutes ()
{
$router = $this->_front->getRouter(); // returns a rewrite router by default
$router->addRoute(
'cat-item',
new Zend_Controller_Router_Route('/:category',
array(
'module' => 'items',
'controller' => 'index',
'action' => 'index'))
);
}
Witch points to the correct location ( I know because I var_dump -ed the request url into the items/index/index action and the expected url and parameters were there, but if I do not do var_dump(something);exit; into the action, a blank page is served.
no output is made but also no error is generated, the request status is 200 - OK
Can anybody have a suggestion ?
Thank you!
I use Navigation component for site menus. I also use let zend figure-out the selected menu item from request parameters - I guess this is done automatically. The only problem is, that for this to work, action and controller have to be specified in navigation configuration for every node. This also means that when zend generates links from route, action and controller information to appended to the generated link automatically.
Anyone had the same problem?
Zend manual section, explaining the Mvc navigation page features.
Example:
some route defined in bootstrap:
$router->addRoute('user_profile_tab', new Zend_Controller_Router_Route(
'profil/:user/:location/:tab/*',
array(
'action' => 'profile',
'controller' => 'user',
'user' => ($user ? $user->id : 0), //change later
'location' => 0 //inject appropriate value later
)
));
navigation container object:
$container = .....
......,
array(
'label' => tr('Privileges'),
'id' => 'user-profile-perms',
'type' => 'Zulu_Navigation_Page',
'controller' => 'user',
'action' => 'profile',
'route'=> 'user_profile_tab',
'params' => array('tab'=>Main_Lib_Common::NAVI_USER_TAB_PERMS)
)
);
the result when using
$page = $container->getById('user-profile-perms');
$page->href;
http://www.example.com/profil/1/0/3/controller/user/action/profile
WHY action and controler params in the navigation container object you ask. The $page->isActive() check needs this data to make a perfect match.
THE FIX:
extend mvc navigation page and provide an alternative getHref() method ... one that removes action, controller and module params when a route does not define them.
I have done this to fix this weird behaviour:
extend mvc navigation page
provide an alternative getHref() method
check for routes, not having action , controller and module parameters and remove them from params array before href generation.
This way the isActive matching will still work, as we didnt modify the route or navigation nodes in any way.