Content Friendly URL?
This is one of those tidbits you get served on a platter if you're lucky enough to attend a Liferay training session. Anyway, content friendly url may not be the legit term, but what I'm referring to is a URL crafted using a Journal Article's urlTitle attribute, which is stored in every journalarticle record btw.
The standard format of such a URL is;
http(s)://<sitename>/-/<article-urlTitle>
For example:
http://renegadehacker.com/-/about-the-hacker
The Setup
So how do we get such a URL to become available to us? Here are the steps. For convenience, consider we have a content structure named XYZ .
- Create a page XYZ Detail. Check the box to hide from navigation. You do this because this page is going to serve as a sort of placeholder to pickup and serve the requested content automagically (calm down: no magic, all science).
- Add an Asset Publisher portlet to that XYZ Detail page.
- Configure that Asset Publisher portlet instance to bring back Web Content Article having subtype XYZ (this corresponds to the structure for your content).
- On the Display Settings tab of the Asset Publisher portlet, click the checkbox to Set as the default Asset Publisher for this page.
- (IMPORTANT and easy to miss) Edit each course content item, click the Display Page option on the right-hand-side. Select the XYZ Detail page as the display page.
Now, if you have a web content item (aka journalarticle for newbies) with a title: The Rain in Spain stays mainly in the plain, you will be able to get to it using:
http://renegadehacker.com/-/the-rain-in-spain-stays-mainly-in-the-plain/
It Doesn't Work!
One thing to try out (apart from ensuring you carried out the above steps) is to check the urlTitle for that journal article in the journalarticle table of your database. Good chance it is quite different than what you expected it to be. Well, that is what you have to use, and that is what the urlTitle reserved variable in velocity brings back. But why is it different?
Here is what I noticed:
The very first value you give to the title gets copied into the urltitle for your article and it sticks no matter what you change the title to after that.
And that my friends, is your friendly report on content friendly URLs, if that be the friendly term for it.