Message Boards
Show popup greeting on site load
Show popup greeting on site load
New Member Posts: 18 Join Date: 5/15/17 Recent PostsHi All
I need to show a popu greeting like below when the site loads:
Could anyone suggest how may I do this? Thanks
RE: Show popup greeting on site load
Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent PostsI am not sure what your issue is. I guess, you know how to show a modal dialog?
Just use AUI().ready() to execute your code to show it. For some circumstances you might also need to implement Liferay.on('endNavigate', ...
https://help.liferay.com/hc/en-us/articles/360017900872-Understanding-Your-Theme-s-JavaScript-Callbacks-in-main-js
https://help.liferay.com/hc/en-us/articles/360017886192-Automatic-Single-Page-Applications
RE: Show popup greeting on site load
New Member Posts: 18 Join Date: 5/15/17 Recent PostsHi Christoph
I just tested and alert and it works, thanks a lot.
RE: Show popup greeting on site load
New Member Posts: 18 Join Date: 5/15/17 Recent PostsHi Christoph
I can show the pouup now but the problem is it's happening on every page load. Would it be possible to set only on Homepage load? And also if possible only the 1st time. Appreciate if you could suggest some right way to accomplish this. Following is my current code inside man.js:
Liferay.on(
'allPortletsReady',/*
This function gets loaded when everything, including the portlets, is on
the page.
*/
function() {
// the dialog
Liferay.Util.openWindow(
{
dialog: {
destroyOnHide: true,
bodyContent: '<div id="dialogBody" class="bgimg"></div>',
centered: true,
height: 500,
width: 500,
},
dialogIframe: {
},
title: 'IXEON Greeting',
}
);}
);
Thanks
RE: Show popup greeting on site load
Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent PostsIf you need to do it only on one page, you could either place the trigger in a webcontent or add a theme setting to enable the feature only on selected places.
To only show it once, you need to set a cookie that disables the popup after the first load. I just did a quick search and found e.g. this code https://gist.github.com/bavington/6727776
The same idea should work for you.
RE: RE: Show popup greeting on site load
New Member Posts: 18 Join Date: 5/15/17 Recent PostsHi Christoph
Could you tell a bit in detail on this "add a theme setting to enable the feature only on selected places"? How to do this theme setting? Thanks
--Rashed