Route

Description

The route property type allows to generate urls for pages, articles and custom entities.

For custom entities, see RouteBundle to implement routing with a RouteDefaultsProvider.

Parameters

Parameter

Type

Description

mode

string

Defines the mode of the input field, can either be “tree_full_edit” or “tree_leaf_edit”. Default value is “tree_full_edit”. Pages get their config from webspace configuration.

route_schema

string

Route schema that is used for generating the url. For pages, the route schema is defined in the webspace configuration, so you usually do not need to set this parameter. For articles and custom entities, you can define the schema using expression language. Within the expression, the variable object is available and contains an array with the values of all properties tagged with the sulu.rlp.part tag (see the example below). See RouteBundle for available variables and functions.

Example

<property name="title" type="text_line" mandatory="true">
    <tag name="sulu.rlp.part"/>
</property>

<property name="url" type="route" mandatory="true">
    <meta>
        <title lang="en">URL</title>
    </meta>

    <params>
        <param name="mode" value="tree_full_edit"/>
        <param name="route_schema" value="/events/{implode('-', object)}"/>
    </params>

    <tag name="sulu.rlp"/>
</property>

Route Parts

Properties tagged with <tag name="sulu.rlp.part"/> are included in the object variable available in the route schema expression. This allows dynamic URL generation based on content field values.

Tags

Tag

Description

sulu.rlp

Marks this property as the route/URL field

sulu.rlp.part

Marks a property as part of the route generation (included in object)

Twig

You need to use the sulu_content_path twig extension to render the full url.

{{ sulu_content_path(content.url) }}