Skip to content

Instantly share code, notes, and snippets.

@harmstyler
Created July 25, 2014 14:31
Show Gist options
  • Save harmstyler/40d1ba5df71d9a67f5d7 to your computer and use it in GitHub Desktop.
Save harmstyler/40d1ba5df71d9a67f5d7 to your computer and use it in GitHub Desktop.
ezpublish:
system:
front_siteaccess:
locaction_view: # This Works
embed:
folder:
controller: "AcmeWebBundle:Content:listAllFolderChildren"
template: AcmeWebBundle:embed:folder.html.twig
match:
Identifier\ContentType: [folder]
content_view: # providing a controller does not work here
embed:
folder:
controller: "AcmeWebBundle:Content:listAllFolderChildren"
template: AcmeWebBundle:embed:folder.html.twig
match:
Identifier\ContentType: [folder]
@ernestob
Copy link

This is not possible yet.
I don't know what version of eZ Publish are you using but it isn't possible in 5.2 haven't tested on 5.3.

The way I tricked this is calling the controller from inside the template and using other twig template to render it

ezpublish:
    system:
        front_siteaccess:
            content_view: # providing a controller does not work here
                embed:
                    folder:
                        template: AcmeWebBundle:embed:folder.html.twig
                        match:
                            Identifier\ContentType: [folder]
                full:
                    folder:
                        template: AcmeWebBundle:full:folder.html.twig
                        match:
                            Identifier\ContentType: [folder]
{# AcmeWebBundle:embed:folder.html.twig #}
{{ render( controller("AcmeWebBundle:Content:listAllFolderChildren", {"contentId": content.contentInfo.id } ) ) }}

and from the controller is where we call the other template, I know it is not optimal but works

public function listAllFolderChildrenAction( $contentId, $viewType = '', $layout = false, array $params = array() )
{
    // do your logic

    // Note we are using the full view now instead of the embed one
    return $this->get( 'ez_content' )->viewContent( $contentId, 'full', $layout, $params );
}

Good look with it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment