I'm using TYPO3 13.1.1 and I delevoped a custom extension in order to display on the front-end side some stuff generated by one of my extension Controller.
-> My extension was installed via Composer, and is displayed in the Extension back-end tab. -> For the moment, I just need to output a "Hello World!" via a plugin
What I see on the front-end : Error "Oops, an error occurred"
My ProductSpaceController.php
:
<?php
namespace Company\Controller;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class ProductSpaceController extends ActionController
{
public function testAction()
{
return 'Hello World';
}
}
My ext_localconf.php
:
<?php
declare(strict_types=1);
use MyCompany\Controller\ProductSpaceController;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
defined('TYPO3') or die('Access denied.');
ExtensionUtility::configurePlugin
(
'company',
'displaymatrice',
[
ProductSpaceController::class => 'test',
],
[
ProductSpaceController::class => 'test',
]
);
My Configuration/Services.yaml
:
services:
_defaults:
autowire: true
autoconfigure: true
public: false
Company\:
resource: '../Classes/*'
My typoscript:
lib.testoutput = USER_INT // I also tried COA, USER
lib.testoutput < tt_content.list.20.company_displaymatrice
When I try to display in fluid, I get the error:
<f:cObject typoscriptObjectPath="lib.testoutput" />
PS: I have other "lib.xxx" that already work (for my top menu, my footer menu, my breadcrumb, my lang switcher etc...)
As Julian Hofmann mentioned above tt_content.list.20.company_displaymatrice
already contains the needed EXTBASEPLUGIN
object.
So you don't need this line in your TypoScript:
lib.testoutput = USER_INT // I also tried COA, USER
Since TYPO3 12 it's mandatory, that controller actions returns an instance of ResponseInterface. See here:
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/Extbase/Reference/Controller/ActionController.html#actions
So your action needs to look like this:
public function testAction()
{
return $this->htmlResponse('<p>Hello World</p>');
}