Hiding a Web Content Viewer JSR 286 Portlet if no content is found

379 Views Asked by At

I have configured a JSR 286 portlet on my portal page which points to a content item. The content item has an expiry date. Once the content expires the user sees default warning message saying no content found for the selected site area.

I want this portlet should not be rendered if there is no content in the selected site area instead of showing a warning.

2

There are 2 best solutions below

0
ZeekLTK On BEST ANSWER

Use a Menu Component that is set to only display 1 item for your portlet. Then create a second content item that has a Presentation Template that just says something like this:

<div class="emptyPortlet" style="display:none;"> This is an empty template. </div>

*if you don't want to declare the style inside the tag, you could also specify .emptyPortlet { display: none;} inside your CSS file.

Publish this before your other item and then set the Menu Component to display based on Publish Date. This way, when you create another item that you want to display (which uses a different Presentation Template), it will have a more recent publish date and will be shown on the page. But, once that is expired, the only published item left to find will be this blank one, and with "display: none" it will essentially hide the entire portlet from the user.

0
Crosstalk22 On

You have a few options Easiest would be to create a custom skin that shows or does not show depending on it's internal contents. just create your own skin to return nothing

Your other options include scraping it out of the response with a servlet filter or some other mechanism or stripping it from the page once you have started rendering