pop-up mod/code change phpbb 3

phpBB3 Olympus MOD Database
-- Categories --

To submit your MOD or style, go to the STG MOD Manager
Forum rules
Image Please feel free to download any MOD's here, support for each MOD is located it's own topic.
We may occasionally notify users of featured MODs or important updates of specific MODs listed in these forums.

General MOD discussions may take place here. -- Not in the subforums.
The subforums are for released MODs ONLY.

MOD Support only in specific MOD topic
No phpBB3 Support


To post your own MOD, style, script or BBCode, go to the MOD Manager

pop-up mod/code change phpbb 3

Postby MGabriella » 12 May 2010, 03:07

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?
MGabriella
Crewman
Crewman
 
Posts: 2
Joined: 12 May 2010, 03:00
Gender: Female
phpBB Knowledge: 4


Re: pop-up mod/code change phpbb 3

Postby Krupski » 15 Jun 2010, 21:58

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(/&amp;/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.
''Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto.'' -- Mikhail T. Kalashnikov
User avatar
Krupski    
Lieutenant
Lieutenant
 
Posts: 287
Joined: 26 Mar 2010, 20:25
Location: PHPBB 3.0.10 with full WYSIWYG Editor. Try it with UN: "tester" and PW: "tester"
Gender: Male
phpBB Knowledge: 5


Return to phpBB3 Olympus MODs / Add-ons Database

Who is online

Users browsing this forum: No registered users and 5 guests