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
How to get the Expiry Date of a Web Content item in an .FTL
Hi,
I have expired a piece of web content, which now no longer appears on the site. However Google has indexed the url and if you search for a particular term, Google returns a result set that contains the page with this webcontent. When you click on the link from Google, it does take you to that expired piece of web content, which is not desirable.
The page has been constructed using a display-page and having an asset publisher portlet to render the web content. Because of this, it is not checking for expired content and renders the content if you hit the url.
My possible solution for fixing this is to check the expiry date of the web content in the freemarker template and if the content has expired, then redirect to a 404 page. My challenge now is getting the expiry date. Using the AssetEntry object when I try to get the expirationDate it returns a null even though the content has been expired.
I printed out the AssetEntry object to the screen ${assetEntry.toString()} and I can see the expirationDate=null.
Any help would be much appreciated.
Using Liferay 7.1.3 CE GA4
Thanks
Mashuk
I have expired a piece of web content, which now no longer appears on the site. However Google has indexed the url and if you search for a particular term, Google returns a result set that contains the page with this webcontent. When you click on the link from Google, it does take you to that expired piece of web content, which is not desirable.
The page has been constructed using a display-page and having an asset publisher portlet to render the web content. Because of this, it is not checking for expired content and renders the content if you hit the url.
My possible solution for fixing this is to check the expiry date of the web content in the freemarker template and if the content has expired, then redirect to a 404 page. My challenge now is getting the expiry date. Using the AssetEntry object when I try to get the expirationDate it returns a null even though the content has been expired.
I printed out the AssetEntry object to the screen ${assetEntry.toString()} and I can see the expirationDate=null.
Any help would be much appreciated.
Using Liferay 7.1.3 CE GA4
Thanks
Mashuk
Hi,
You can access assetRenderer and check whether asset is displayable or not , below method will check whether article is expired or not.
Also you can fetch expiration date as below
You can access assetRenderer and check whether asset is displayable or not , below method will check whether article is expired or not.
${entry.getAssetRenderer().isDisplayable()?then('Y', 'N')}
Also you can fetch expiration date as below
${entry.getAssetRenderer().getArticle().getExpirationDate()}
Thanks Mohammed, that works great

Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™