MGabriella wrote:i need a mod to show a banner (pop-up when clicked) (for my chat room) but i want it hidden to my guests, so they would need to registrer to enter the chat.
is there a mod like that out there already?
the link feature in phpbb 3, makes it possible to add a link to you`re forum, and hide it.. but i want a popup.. and a certain size to the pop-up window... any idea on how i could modify the link feature in phpbb3?
You want to pop-up a new window on top of the current window? And make it a certain size?
Here's a piece of Javascript that I use to make a pop-up window that closes after a specified timeout:
- Code: Select all
/** "global" **/
var win = new Array();
var idx = 0;
/***
* popup window in the center with a timeout
**/
function pop(url, width, height, timeout)
{
var lpos = (screen.width) ? (screen.width - width) * (1/2) : 0; /* centered L-R */
var tpos = (screen.height) ? (screen.height - height) * (1/3) : 0; /* 1/3 from the top */
timeout = timeout ? timeout : 5000; /* default timeout 5 seconds */
var settings = 'height=' + height + ',width=' + width + ',top=' + tpos + ',left=' + lpos;
win[++idx] = window.open(url.replace(/&/g, '&'), '', settings);
setTimeout('while(idx > 0) { win[idx--].window.close(); }', timeout); /* close all pops after timeout */
return false;
}
You can cut-n-paste that code into 'phpBB3/styles/your-style/template/editor.js', and to use it, call it like this:
pop('page-to-display.html', 400, 300, 3000);
That will pop up a window 400 pixels wide by 300 pixels high, display the contents of 'page-to-display.html' and it will self-close after 3000 milliseconds (3 seconds).
Or, you can put it into an "onclick" event of a button or an anchor (link)... same result.
Now, to hide it from guests, you would use <!-- IF ... --> statements in your HTML code (probably in viewtopic.html or index_body.html).
Put it all together and you would have this:
- Code: Select all
<!-- IF S_USER_LOGGED_IN and not S_IS_BOT -->
<a href="" onclick="return pop('web-page.html','400','300','10000');">Click here for popup!</a>
<!-- ENDIF -->
The clickable link will only be visible to a user who is logged in and who is NOT a "bot".
When you click the link, it will open "web-page.html' in a 400 x 300 window which will self-close after 10 seconds.
If you want to quick-test how it works, just copy and paste this HTML below into a file named "test.html", then open it in your browser. The <!-- IF --> statements aren't in there because the test.html file is stand-alone and doesn't have access to PHPBB3 variables (i.e. they wouldn't work in the demo).
When you click the link, it will open itself again in a popup, then close after 3 seconds. The button does the same thing (opens the popup). It's just there to show you how to do a button as well as a link.
- Code: Select all
<html>
<head>
<script type="text/javascript">
/** "global" **/
var win = new Array();
var idx = 0;
/***
* popup window in the center with a timeout
**/
function pop(url, width, height, timeout)
{
var lpos = (screen.width) ? (screen.width - width) * (1/2) : 0; /* centered L-R */
var tpos = (screen.height) ? (screen.height - height) * (1/3) : 0; /* 1/3 from the top */
timeout = timeout ? timeout : 5000; /* default timeout 5 seconds */
var settings = 'height=' + height + ',width=' + width + ',top=' + tpos + ',left=' + lpos;
win[++idx] = window.open(url.replace(/&/g, '&'), '', settings);
setTimeout('while(idx > 0) { win[idx--].window.close(); }', timeout); /* close all pops after timeout */
return false;
}
</script>
</head>
<body>
<a href="" onclick="return pop('test.html','400','300','3000');">Click here for popup!</a>
<br />
<br />
<button type="button" onclick="return pop('test.html','400','300','3000');">Click here for popup!</button>
</body>
</html>
Hope this gets you on the path to doing what you want to do....
-- Roger
(p.s. the rather strange loop at the end of the Javascript that closes all the windows it opened is to handle if someone clicks the link several times and opens one window on top of another... so they all get closed after the timeout. Note though that if you refresh the page or navigate away from the page WHILE the popup is still open, it will remain open and not self close.) Try clicking the link more than once... watch how ALL the popup windows self close after the timeout.