user1738984
user1738984

Reputation: 604

FluidTYPO3 fluidpages – custom page controller not found

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 :

And 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

Answers (1)

user1738984
user1738984

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

Related Questions