Page Alias based on part of a field

Sylvain C. asked on January 18, 2020 00:53

Hello,

In my staff pagetype, I have an email field (eg.: first.last@email.com). I would like my page alias to be only based on the first part of the email (something like first.last). In the interface, I can only choose a field in particular for my page alias.

How can I make it happen?

Thank you

Sylvain

Recent Answers


Michael Eustace answered on January 20, 2020 18:27

One approach would be to write some custom code which hooks in to the DocumentEvents.Insert.After global event which would update the auto-generated page alias into the format you want it to be i.e. "first-last".

Note I've used a hyphen "-" to seperate the first and last name as you wouldn't normally use a "." in a URL other than for a file extension at the end of the URL.

If your staff page type has fields for first and last names you could use the values of these fields to construct the new page alias instead of having to perform a substring on the email address to get everything before the "@" symbol.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.