Version

Documentation » Page

9. Command Line Tools »

« 7. Error Pages

8. Twig Helpers

8.1. URL

Render a page url

{{ path(page) }} => /absolute/path/to/url

{{ path(page, {}, true) }} => ../relative/path/to/url

{{ url(page) }} => https://sonata-project.org/absolute/url/to/url

{{ url(page, {}, true) }} => //sonata-project.org/network/path/to/url

Render a block url to render it in AJAX (given we have a block id = 1 used on a page id = 2)

{{ sonata_page_ajax_url(block) }} => /index.php/_page/block/2/1

{{ sonata_page_ajax_url(block, {'parameter': 'value'}) }} => /index.php/_page/block/2/1?parameter=value

{{ sonata_page_ajax_url(block, {'parameter': 'value'}, true) }} => https://sonata-project.org/index.php/_page/block/2/1?parameter=value

8.2. Container

Render a container using the current page

{{ sonata_page_render_container('name') }}

Render a container using a transversal page named blog

{{ sonata_page_render_container('name', '_blog') }}

Render a container using a page instance

{{ sonata_page_render_container('name', page) }}

Optionally, you can pass as a third argument some settings that will override original container settings:

{{ sonata_page_render_container('name', page, {key: value}) }}

8.4. Assets

{% for js in sonata_page.assets.javascripts %}
    {# ... #}
{% endfor %}

This allows to access the javascripts and css assets configured in sonata_page configuration.

Found a typo? Something is wrong in this documentation? Just fork and edit it!