sulu-link ========= The sulu-link tag allows to link to pages and other entities in the application by their id. This id of the tag will be validated and replaced by a proper anchor tag when a response is generated. Furthermore, the sulu-link tag allows to add a query string (?) or an hash (#) that is forwarded to the resulting anchor. In a basic installation, the tag supports 2 different providers: ``page`` (default) and ``media``. Additional providers can be implemented by :doc:`registering a service with the sulu.link.provider tag<../../cookbook/link-provider>`. Example ------- .. code-block:: html Link Text Anchor Example Query String Example Link Text Link Text **Results into:** .. code-block:: html Page Title Page Title Link Text Anchor Example Query String Example Link Text Media Title Link Text Provider Attributes ------------------- There might be situations where you need to know which provider was used even after the tag was converted to an anchor tag. In that case you can use the provider attributes feature to pass the provider information as a data attribute to the rendered anchor tag. .. code-block:: yaml # config/packages/sulu_markup.yaml sulu_markup: link_tag: provider_attribute: 'data-provider' **Example:** .. code-block:: html Link Text **Results into:** .. code-block:: html Link Text Media Title Now you will be able to target the links in CSS and Javascript by using the data attribute as a selector. This allows things such as: * Adding an icon to download (media) links * Format internal links differently * Add custom analytics **Example:** .. code-block:: css a[data-provider="media"] { font-color: green; } How the tag is processed ------------------------ The ```` tag is processed after the response content is generated and before it is sent to the client. A parser detects all links and loads the paths of all linked pages from the PHPCR in a *single* query. If a twig function would be used to generate the links, each call would trigger a request to the PHPCR which would worsen the performance.