Message Boards
How to get the Expiry Date of a Web Content item in an .FTL
Mashuk Choudhury, modified 3 Years ago.
How to get the Expiry Date of a Web Content item in an .FTL
Junior Member Posts: 33 Join Date: 1/31/14 Recent Posts
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
Mohammed Yasin, modified 3 Years ago.
RE: How to get the Expiry Date of a Web Content item in an .FTL
Liferay Master Posts: 591 Join Date: 8/8/14 Recent Posts
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()}
Mashuk Choudhury, modified 3 Years ago.
RE: How to get the Expiry Date of a Web Content item in an .FTL
Junior Member Posts: 33 Join Date: 1/31/14 Recent Posts
Thanks Mohammed, that works great