Is it possible to add an entry value to the entry URL Format? I try to compose an entry URL for artists pages with first name and last name.

Now:

artists/{slug} = artists/{{ entry.title }}
{slug} = {{ entry.title }} = Artist Last Name


What I want to add at the end of the URL (Plain Text field):

{{ entry.artistFirstName }} = Artist First Name


What I try to get, but which is not working:

artists/{slug}-{{ entry.artistFirstName }}


Is it possible? how? And how can I add a conditional to check if entry.artistFirstName is defined?

Thanks!
For this a good approach is to use the excellent Dynamic Routing system in Craft.

Solution #1

First create your section "Artists":



After that go to "Settings" -> "Routes" and add this Dynamic Route:



When this is done all URL requests made to "/artists/-whatever-" will be routed to the "artists/_entry" template. Now you can create your link like this:

&lt;a href="/artists/{{ entry.slug }}/{{ entry.firstNameField }}/{{ entry.lastNameField }}"&gt;Artist Name&lt;/a&gt;


Your URL might now look like this rendered:

&lt;a href="/artists/ladygaga/firstname/lastname"&gt;Lady Gaga&lt;/a&gt;


In your "_entry" template you can now fetch your entry using this code:

{% set entry = craft.entries.section('artists').slug(craft.request.getSegment(2)).first() %}
Artist Name: {{ entry.title }}


Solution #2

If you instead want the URL to be "/artists/firstname-slug" you can alter the Dynamic Route slightly and use the Twig filter "split" to get the slug from the URL.

First change the Dynamic Route to:

artists/*


Then update your template "_entry" with the following code:

{% set segments = craft.request.getSegment(2)|split('-') %}
{% set entry = craft.entries.section('pages').slug(segments[1]).first() %}
Title: {{ entry.title }}


Your URL can now be "/artists/{{ entry.firstNameField }}-{{ entry.slug }}" and the template code will take care of the rest.