Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@ernestob ernestob commented Jul 25, 2014

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