There is some small detail I seem to be missing but I just can't find out what it is...
I get this error:
Error: The ViewHelper "<ugh:example>" could not be resolved. Based on your spelling, the system would load the class "TYPO3\Projectname\ViewHelpers\ExampleViewHelper", however this class does not exist.
I have my own extension called sitepackage
, which works without issues.
In my ext_localconf.php
I wrote
$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['ugh'] = ['TYPO3\\Projectname\\ViewHelpers'];
Then there's the directory ViewHelpers
inside Classes
with the file ExampleViewHelper.php
<?php
namespace TYPO3\Projectname\ViewHelpers;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
// etc ...
I expect it to use like <ugh:example />
What am I missing? Is there something outside of this that I have to do? I'm freaking out about this...
Your global configuration works, yet PHP is not able to find your TYPO3\Projectname\ViewHelpers\ExampleViewHelper
.
I suspect that you have a spelling error or your autoloading information is out of date (assuming a composer-based installation, composer dump-autoload
updates it) or you forgot to add your namespace to composer.json
(see composer docs or a TYPO3 extension example here).
That said, the usual approach is to add ViewHelper namespaces to the Fluid template directly. See https://docs.typo3.org/m/typo3/book-extbasefluid/10.4/en-us/8-Fluid/8-developing-a-custom-viewhelper.html#importing-namespaces
Without composer
Use TYPO3 InstallTool "rebuild autoload information" or similar to build the class autoloading information. I think ext_emconf.php needs to contain the autoloading information, too.