This post demonstrates creating user-friendly URLs in Site Studio for secondary pages (think dynamic lists). When you execute the SS_GET_SEARCH_RESULTS service a resultset named SearchResults is returned. While looping that resultset writing out URLs you should find a variable/column named SSUrl. The default value for SSUrl will use the Content ID like this:
We can change this behavior by adding a configuration variable to the General Configuration section of Content Server named SSUrlFieldName. We set this variable to the name of a metadata field we can use to control the end of the URL. This enables us to construct URLs like this instead:
To enable this functionality we first need to create a metadata field that we can use to control the end of the URL.
On the edit Metadata Field screen set the Field Caption to Page Name, set Field Type to Long Text and Click OK. Afterwards don’t forget to click “Update Database Design” and “Rebuild Search Index” if necessary.
Log into your Content Server and open Administration > Admin Server > General Configuration. Add the following setting to the General Configuration and set it to the name of the new metadata field you created a moment ago. Example:
Click save to persist your changes and then restart the Content Server.
Now, when you check in a piece of content you will be able to specify the page name for the content. Traditionally the URL will look like this:
But if I supply a value for our new Page Name metadata field like TimSmithNewHire the URL will now look like this:
I can also add a “.htm” or “.html” to the value in my field to give the URL a more traditional look and feel like this:
Finally, if you want, you can add a little IdocScript to the derived value for the field in a profile and do things like drop out spaces or ensure that the contributor added htm or html to the end fo the supplied page name. Here is a sample:
<$pagename = #active.xSSPageName$>
<$pagename = strRemoveWs(pagename)$>
<$dprDerivedValue = pagename$>
<$if not (pagename like "*htm|*html")$>
<$dprDerivedValue = pagename & ".htm"$>