Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to set the web content display portlet to show the latest version ?
The web content display portlet displays the latest approved vesion of a web content. Our client needs to see the latest version (approved / unapproved) on the actual page before approving and opening to the end users.
for example: if latest approved version is 1.2 then the business would like to see version 1.3 on the page which can be on any other status(pending,draft,schduled etc).
How to implement this?
Regards!
for example: if latest approved version is 1.2 then the business would like to see version 1.3 on the page which can be on any other status(pending,draft,schduled etc).
How to implement this?
Regards!
The Web content display portlet will show the latest approved article by default. if your client wants to achieve the behavious as you mentioned, here is the different approach
1. Control Panel : Assign Web Content Admin role to the user and admin user can go to control panel web content portlet and can view all the history of articles ( versions / status)
2. Custom Portlet: Create Custom Portlet and display all the contents irrespective of versions or status using Journal API for the Particular Role.
3. Web Content Hook : (Not Recommended) if client doesn't satisfy for the above approaches and he wants to the same behaviour in OOTB portlet then you can customize existing beheviour thorugh MVCActionCommand / MVCRenderCommand or jsp hook to achieve this.
HTH.
1. Control Panel : Assign Web Content Admin role to the user and admin user can go to control panel web content portlet and can view all the history of articles ( versions / status)
2. Custom Portlet: Create Custom Portlet and display all the contents irrespective of versions or status using Journal API for the Particular Role.
3. Web Content Hook : (Not Recommended) if client doesn't satisfy for the above approaches and he wants to the same behaviour in OOTB portlet then you can customize existing beheviour thorugh MVCActionCommand / MVCRenderCommand or jsp hook to achieve this.
HTH.
Thanks for the response.
We have had already considered and dropped the solutions 2 & 3. The problem with solution 2 is that the content management team doesn't like a custom portlet, as they are comfortable with OOB portlet especially it's drag and drop feature of the content on a page. Solution 3 as you said we also don't recommend.
The solution 1, I don't understand clearly could you please explain that? Also we only want our admin users to see the latest version the public users should't see that. Also the latest content may not have published any single time so it won't even appear on the web content display portlet we need to change this too. The whole idea behind this is to allow admin users to verify a content on a page before it goes to the customers.
Cheers!
We have had already considered and dropped the solutions 2 & 3. The problem with solution 2 is that the content management team doesn't like a custom portlet, as they are comfortable with OOB portlet especially it's drag and drop feature of the content on a page. Solution 3 as you said we also don't recommend.
The solution 1, I don't understand clearly could you please explain that? Also we only want our admin users to see the latest version the public users should't see that. Also the latest content may not have published any single time so it won't even appear on the web content display portlet we need to change this too. The whole idea behind this is to allow admin users to verify a content on a page before it goes to the customers.
Cheers!
Vishnu,
I think he was suggesting using the roles to allow for preview, but I'm not sure that will provide the in context approach that I think you are after. I have an alternative suggestion that would work with all out of the box stuff, but might not be the most awesome solution.
Instead of using the web content display, use an Asset Publisher, where you specify the item you want to render (don't do the dynamic option, use the other one .. the name of which escapes me). Then, in your ADT, you can use the JournalArticleLocalService to see if there is a newer (unapporved) version and if there is, and the user has the right role to view it, then render the unapproved version in place of the approved one.
The ADT wouldn't contain any of the "template view" in it, just the logic for the decision of which version to render. Actually, come to think of it, you don't need the Asset Publisher/ADT -- you could introduce the logic into you WCM template in the same fashion
I nice solution might be to try this --
1. In your WCM, detect if the user has the rights to see unapproved content.
2. If they do, give them a toggle to "preview unpublished"
3. By default you render the approved but if they hit that toggle, you re-render with the unapproved one
.. anyway, you can do it by introducing some logic into your template. Not the best practice mind you as templates shouldn't really be "smart", but if you have no other choise, I think that would work.
I think he was suggesting using the roles to allow for preview, but I'm not sure that will provide the in context approach that I think you are after. I have an alternative suggestion that would work with all out of the box stuff, but might not be the most awesome solution.
Instead of using the web content display, use an Asset Publisher, where you specify the item you want to render (don't do the dynamic option, use the other one .. the name of which escapes me). Then, in your ADT, you can use the JournalArticleLocalService to see if there is a newer (unapporved) version and if there is, and the user has the right role to view it, then render the unapproved version in place of the approved one.
The ADT wouldn't contain any of the "template view" in it, just the logic for the decision of which version to render. Actually, come to think of it, you don't need the Asset Publisher/ADT -- you could introduce the logic into you WCM template in the same fashion

I nice solution might be to try this --
1. In your WCM, detect if the user has the rights to see unapproved content.
2. If they do, give them a toggle to "preview unpublished"
3. By default you render the approved but if they hit that toggle, you re-render with the unapproved one
.. anyway, you can do it by introducing some logic into your template. Not the best practice mind you as templates shouldn't really be "smart", but if you have no other choise, I think that would work.
Maybe it is simpler to just hook the view jsp of the webcontent display:
https://github.com/liferay/liferay-portal/blob/master/modules/apps/journal/journal-content-web/src/main/resources/META-INF/resources/view.jsp
https://github.com/liferay/liferay-portal/blob/master/modules/apps/journal/journal-content-web/src/main/resources/META-INF/resources/view.jsp
Christoph RabelMaybe it is simpler to just hook the view jsp of the webcontent display:
https://github.com/liferay/liferay-portal/blob/master/modules/apps/journal/journal-content-web/src/main/resources/META-INF/resources/view.jsp
Thank You Christoph!
Andrew JardineVishnu,
I think he was suggesting using the roles to allow for preview, but I'm not sure that will provide the in context approach that I think you are after. I have an alternative suggestion that would work with all out of the box stuff, but might not be the most awesome solution.
Instead of using the web content display, use an Asset Publisher, where you specify the item you want to render (don't do the dynamic option, use the other one .. the name of which escapes me). Then, in your ADT, you can use the JournalArticleLocalService to see if there is a newer (unapporved) version and if there is, and the user has the right role to view it, then render the unapproved version in place of the approved one.
The ADT wouldn't contain any of the "template view" in it, just the logic for the decision of which version to render. Actually, come to think of it, you don't need the Asset Publisher/ADT -- you could introduce the logic into you WCM template in the same fashion
I nice solution might be to try this --
1. In your WCM, detect if the user has the rights to see unapproved content.
2. If they do, give them a toggle to "preview unpublished"
3. By default you render the approved but if they hit that toggle, you re-render with the unapproved one
.. anyway, you can do it by introducing some logic into your template. Not the best practice mind you as templates shouldn't really be "smart", but if you have no other choise, I think that would work.
Thank you Andrew. This seems to be an excellent solution. We'll bring it up to the business to get their feedback.
Regards!
No problem -- if they approve it and you guys end up putting it into action, I would also suggest maybe circling back to this thread and sharing your template code, or maybe writing a blog post for anyone else that might be after the same type of solution. Best of luck.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™