namespacestypo3fluidview-helpers

TYPO3 8.2: ViewHelper Namespace


I have tried to create multiple ViewHelpers in a TYPO3 extension.

    <?php
namespace PdvPolymer\ViewHelpers;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;

class ButtonUpViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper
{...

The ViewHelper is situated in the directory extension\Classes\ViewHelpers.

This works great when I call it with:

<div xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers" xmlns:p="http://typo3.org/ns/Extension/ViewHelpers">
<p:buttonUp></p:buttonUp>
</div>

But now I have tried to put the ViewHelper in a Sub-Directory like extension\Classes\ViewHelpers\Custom.

The new namespace of the ViewHelper now is:

namespace Extension\ViewHelpers\Custom;

Now I call the ViewHelper with:

<p:custom.buttonUp></p:custom.buttonUp>

...and get an Error like:

Oops, an error occurred! Code: 2016091908135339232bbd 

My question is, what did I wrong? The internal Fluid-Extension in TYPO3 does it all the same like me. I have checked it!

Has someone an idea?


Solution

  • There are 2 different issues.

    First, I would suggest to avoid subdirectories in the namespace declaration and just use xmlns:p="http://typo3.org/ns/Extension/ViewHelpers". Always add the subdirectory path when calling the ViewHelper then in the template, e.g.

     <p:custom.buttonUp></p:custom.buttonUp>
    

    You don't need to the declaration twice.

    2nd) About the error handling

    Use the TypoScript config.contentObjectExceptionHandler = 0 to turn it off for your development system and you will see a more helpful message. You can find more info in the docs.