Reputation: 604
I am building a website with TYPO3 9.5 and the Fluid Powered TYPO3 extensions, and I will need to access GET and POST variables in my fluidpages templates.
I tried to create a custom PageController to do this ; here is the class I added in …myext/Classes/Controller/PageController.php
:
<?php
namespace MyVendor\MyExt\Controller;
use FluidTYPO3\Fluidpages\Controller;
class PageController extends Controller\PageController
{
protected function initializeViewVariables() {
parent::initializeViewVariables();
$GETarray = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET();
$this->view->assign('GET', $GETarray);
}
}
Unfortunately, this method never seems to be executed, as if my class weren’t found. When I display GET
in the template file with <f:debug>{GET}</f:debug>
, the result is always NULL
whatever parameters I added in the URL. I tried assigning another, fixed variable with view->assign
, and it’s NULL
too. The code above does not have syntax errors, I’m using PHPStorm, which finds the parent class and shows that my initializeViewVariables
method overrides the one in AbstractFluxController
.
What I have tried :
MyVendorName.Myextensionkey
. I created a ClassAliasMap.php
file, even though I don’t think it would be needed for TYPO3 9.5 ?composer.json
file in my extension, I added :
"autoload": {
"psr-4": {
"MyVendor\\MyExt\\": "Classes"
}
}
and in the composer.json
for my entire TYPO3 project, I put :
"autoload": {
"psr-4": {
"MyVendor\\MyExt\\": "public/typo3conf/ext/myext/Classes"
}
}
and I have verified that this path appears in vendor/composer/autoload_psr4.php
after I used the composer dump-autoload
command. I also have the autoload information in the ext_emconf.php
fileAnd it still doesn’t work. Autoloading works if I call a method of a class in the Typoscript of a page with userFunc
, however. Do you see what I am missing?
Upvotes: 1
Views: 446
Reputation: 604
Answering my own question for now (hopefully I will be able to add more details later) : in order to have the above Controller be called for a certain page, we need to add an action, even an empty one, with the same name as the template. For example if our page template is Foo.html
, it will work if we add an action method :
public function fooAction() {
}
to the PageController
class
Upvotes: 0