Sign Out link in the session inactivity pop up

2019-02-26 21:46发布

问题:

How can i add one Sign Out link in the session inactivity pop up in liferay? Currently we don't have any hyperlink in that pop-up .We are having only the warning messages. Please help me how to solve this as i'm new to liferay.

Thanks, Sourav

回答1:

Here's the way to solve it: You can look up the warning text itself in Liferay. You'll find it in the translation files (portal-impl/src/content/Language*.properties. One method is to add the HTML required just there (the key, as you'll easily find, is warning-your-session-will-expire)

If you're not comfortable adding it there (Translation files are not my favourite place to add HTML markup) you'll have to find occurrences of this key elsewhere in Liferay. You'll find it in portal-web/docroot/html/js/liferay/session.js. The first occurrence there says

 instance._warningText = Liferay.Language.get('warning-your-session-will-expire');

You can easily customize the text here, e.g. with

 instance._warningText = 
    Liferay.Language.get('warning-your-session-will-expire') + 
    ' <a href="/c/portal/logout">' + 
    Liferay.Language.get('sign-out') +
    '</a>';

(note that this is omitting the possibility that Liferay is running in a different context, e.g. not on /)

Alternatively, just search for more occurrences of instance._warningText and you'll find where it's used and can use other places to change the content of the message (hint: it's in the same file)

Despite session.js being a javascript file, you can actually build a jsp hook and override this file with the same technique as you'd override a jsp file. You might need to clean out temporary files in your appserver though, as this file might have been minified & cached with other javascript resources.



标签: liferay