You want to have a link to a WebContent in Liferay, to send to a colleague or a friend. This friend should then look at the WebContent without having to navigate through Liferay. And : This should be as flexible as possible, without having to create a WebContent Display Portlet for each created WebContent.
There are actually two solutions:
1 Linking diretly to the WebContent:
If you link diretly to the WebContent, the WebContent is shown without showing the Portal itself. Just as you would link directly to an html page. This is what you need to do to get the link:
Add portalURL and pathMain together to create a link to the Server Liferay is running on :
Add the Path to directly view a WebContent:
Add GroupId, ArticleId and Version of the WebContent you want to display :
This creates something like the following which you can send by email:
2 Linking to an asset publisher
If you want to display the WebContent IN the portal, so that the User afterwards can start to explore your portal (maybe you want to lure some customers onto your website) you can do the following :
To summarize it : We deploy an Asset Publisher Portlet to the portal, search this Asset Publisher in our code and pass the Web Content data to it.
2.1 Prepare the portal
At first, create a new site in your portal, that will only take an asset publisher. Then deploy an asset publisher somewhere on that page. This asset publisher will now be the place where all your web contents will be displayed. Enter the Configuration of the asset publisher and change "asset selection" to "manual". That´s all for the asset publisher.
The last thing you have to do is to remember the friendly url that leads to your asset publisher. Look at the status bar of your browser : http://localhost:8080/user/admin/test. In this case it would be "test".
2.2 Navigate to the asset publisher
What your method needs is the friendly url ("test") and the journalArticle (= Web Content) to navigate to the asset publisher. So how do we navigate there ?
First, retrieve all Layouts and inspect the friendlyURL property if it equals the friendly URL you passed into the method:
What you then need to do is to retrieve the UnicodeProperties containing the properties you need to inspect for an asset publisher ID. The asset publisher ID is 101 :
If you have this property, you need the instance ID of the asset publisher to build the link correctly:
And the last step is to combine all that to the link :
Thats all :) Now you can see the Web Content in your Portal by clicking on a link.
If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)
If you have any questions, feel free to leave a comment.