Forum Discussion

Puljac's avatar
Puljac
Maven
11 years ago

Unread messages component

How to make "Unread messages" widget doesn't dissapear and instead of disaapearing to show some custom text like   "You have no new unread messages."   Thanks  
  • AdamN's avatar
    11 years ago

    Hi Puljac,

     

    There's no standard option or setting to enable this type of functionality, but with a little customization you should be able to accomplish this.

     

    This approach will make use of the ability to override standard Lithium components, which you can learn more about here:

    http://lithosphere.lithium.com/t5/support-knowledge-base/Using-override-to-change-core-components/ta-p/61358

     

    Basically what you'll want to do is create a custom component named "forums.widget.unread-messages@override". This will override the standard Unread Messages component. Then, you could add something like this as the content:

    <#assign unreadContent>
    <@delegate />
    </#assign>
    
    <#if unreadContent?? && unreadContent?has_content >
    ${unreadContent}
    <#else>
    You have no new unread messages.
    </#if>

     This first assigns to the variable "unreadContent" the output of the standard component (which is represented here by the "delegate" macro). Next, we check to see if "unreadContent" exists and has any content (basically, is the standard component empty or not). If it has content, we display it. Otherwise, we show the custom message, such as "You have no new unread messages.".

     

    You may need to tweak a bit to add your own content wrapper and style as needed, but hopefully this will get you going in the right direction!