Sitecore tip 42: combine links and text in one SXA navigation component

Recently I was asked if it was possible to combine a couple of hyperlinks and a piece of text into one SXA navigation component. The requirement was to create a horizontal list of hyperlinks for terms and conditions, privacy statement and a copyright message. The first two were hyperlinks to pages and the copyright message was just a text. This would create a better front-end solution and it was needed for the required responsive behaviour.

This can easily be created with the SXA Link List component. In just three simple steps you can achieve this without custom code. Here is how.

1. Two data templates

First configure a new data template for your piece of text. This can be a simple data template based on the default template of Sitecore. It only needs a single line text field to store the value of you text.

2. Create the rendering variant

You will be using the Link List data template in combination with the newly created data template. So create a new rendering variant with two fields:

  • One for the Link List Link data template
  • One for your new template

And here comes the magic: configure a rule for each field that it is only enabled if the item is of the specified data template.

3. Configure a datasource configuration

Finaly create a new datasource configuration for the Link List component (your SXA site/settings/Datasource Configuration). Here you select your custom data template in the “Additional compatible templates” field. This way the Link List component will accept both templates within your site.

There you go. A simple way to make it easier for your front-end developers but also for your content editors.