Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom ViewHelper uses PHPRenderer instead of TwigRenderer #103

Open
castler opened this issue Oct 26, 2014 · 1 comment
Open

Custom ViewHelper uses PHPRenderer instead of TwigRenderer #103

castler opened this issue Oct 26, 2014 · 1 comment

Comments

@castler
Copy link

castler commented Oct 26, 2014

I have custom ViewHelper where I want to use a template.

So in the ViewHelper i write something like

    public function __invoke()
    {
        return $this->getView()->render('templatename.twig', array('foo' => 'bar'));
    }

I register my custom ViewHelper like that

return array(
    'factories' => array(
        'ViewHelperName' => 'ModuleName\Service\Factory\ViewHelperFactory',
    ),
);

and also i register my ViewHelper in the TwigHelperPluginManager

    'zfctwig' => array(
        'helper_manager' => array(
            'configs' => array(
                'Navigation\Service\Factory\NavigationViewHelperNavigation',
                'ViewHelperName',
            ),
        )
    ),

But still the PhpRenderer is used and not the TwigRenderer.

Did I miss something?

Thanks for your help.

@castler castler changed the title Custom ViewHelper doesn't uses PHPRenderer instead of TwigRenderer Custom ViewHelper uses PHPRenderer instead of TwigRenderer Oct 26, 2014
@kokspflanze
Copy link
Contributor

hi for me works

return [
    'view_helpers' => [
        'aliases' => [
            'sidebarWidget' => Helper\SideBarWidget::class,
        ],
        'factories' => [
            Helper\SideBarWidget::class => InvokableFactory::class,
        ],
    ],
    'zfctwig' => [
        'helper_manager' => [
            'configs' => [
                HelperConfig::class
            ],
            'aliases' => [
                'sidebarWidget' => Helper\SideBarWidget::class,
            ],
            'factories' => [
                Helper\SideBarWidget::class => InvokableFactory::class,
            ],
        ],
    ],
];

my sidebar template looks like following

{{ "now"|date('y-m-d') }}

maybe that can help someone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants