Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 04:26:52 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155543 Posts in 21714 Topics by 7736 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: [*droplet*] colorBoxOnLoad (Pop up your Ad)  (Read 1926 times)
Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4884



« on: December 30, 2010, 03:53:09 AM »

Hello,

this is another droplet I'd like to share with you.
Special thanks to user Maverik for help, tips and suggestions.

The droplet is still in development, so you may suggest improvements, wishes...

What is it for?

You can use this droplet to pop up an add, banner, information box on page load.
You will be able to set a expiration time, so the droplet will be loaded only once for a specified time.
You will (need to) specify a Section ID which will be loaded into the ColorBox.
You may use a WYSIWYG or any other kind of Section (not any module makes sense though).
You may also specify the height and width of the box to display.

See it in action
Maverik placed the droplet for testing purposes here:
http://www.websitebaker.net/pages/labor/cbsection.php
(Thanks)

What is needed?
You will need the ColorBox snippet:
DOWNLOAD
Just install it.
You will also need the current "official" jQuery inclusion in you template.
(Maverik's ColorBox snippet makes use of the $insert method included in WB Core).
Ask if you have questions to be answered.

I am sure, the droplet will also work using jQuery Admin if you prefere -
but it would need small adjustments to be done (I guess).


Droplets Parameters

[[ColorboxOnLoad?sID=77&width=640&height=490&expire=600&title="here comes a title"]]

Let's break it down:
?sID=77  -> this is the sectionID you want to fetch the content from (required)

&width=640 (optional, default=550)
&height=490 (optional, default=420)
&expire=600 (optional, default=120) // seconds   
&title="here comes a title" (optional, default (empty))

If you want the Box to pupup at any page load, set
&expire=1.


DROPLETS CODE:
Code: (ColorboxOnLoad)
<?php 
global $database$wb;

//check if sID is set
if(empty($sID) || !is_numeric($sID))
$output '<p>you must specify a sectionID to run the "ColorboxOnLoad" droplet</p>';
else{
$output "";

$cookie "sID_".$sID;

//  EXPIRATION
// @parameter:  'expire'
// @required: no
$expire = (!isset($expire)) ? (120) : $expire;
if (!isset($_COOKIE[$cookie]))  
setcookie($cookie'1'time()+$expire); //setcookie($cookie, '1', time()+60*60*24*7);
else
return $output//we stop the script here
 
  
//  GET SECTION
// @parameter: 'sID'
// @required: yes!
if($module_check $database->get_one(sprintf("SELECT `module` FROM `%s` WHERE `section_id` = '%d'"
TABLE_PREFIX."sections" ,$sID ))) {   

$section_id intval($sID); // [!]variable needed for the included file 
        
ob_start();        
        require(
WB_PATH.'/modules/'.$module_check.'/view.php');
        
// here is our content within two divs, one is hidden via style definition
        
$output .= '<div style="display:none;"><div id="colorbox_section">'.ob_get_contents().'</div></div>';
        
ob_end_clean();            
    } else 
    
// if requested Section doesn't exist
    
$output .= "<p>The requested section wasn't found</p>";
    
    
// width & height
$width  (!isset($width) || !is_numeric($width)) ? ( 550 ) : intval($width);
$height  (!isset($height)|| !is_numeric($height)) ? ( 420 ) : intval($height);

$output .= <<<_SCRIPT
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready( function () {
$('.cboxOnLoad').colorbox({
inline: true, 
href: '#colorbox_section',
innerWidth:
$width
innerHeight:
$height,
maxWidth: "98%",
maxHeight: "98%",
});
$('a.cboxOnLoad').click();
 
});
/* ]]> */
</script>
_SCRIPT;

//  BOX TITLE
// @parameter:  'title'
// @required: no
if(isset($title) && is_string($title)){
$title sprintf(' title="%s"'$title);
$title str_replace('&quot;',''$title);
}else  $title '';

$output .= '<a class="colorbox"></a>'// needed to initialize Maverik's cBox snippet 
$output .= '<a class="cboxOnLoad" '.$title.' href="#"></a>';
}
return 
$output;


?>



Kind Regards,
Stefek


« Last Edit: December 30, 2010, 05:46:14 AM by Stefek » Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
iradj

Offline Offline

Posts: 261



« Reply #1 on: December 31, 2010, 12:24:06 PM »

Christian,

Thank you for that droplet. It is very nice and better than ShowAd. Thanks also to Maverik.

Iradj
Logged
dbs
WebsiteBaker Org e.V.

Offline Offline

Posts: 3719


WWW
« Reply #2 on: January 01, 2011, 12:36:27 PM »

hi, have you a zip of the droplet, for import?
Logged

maverik

Offline Offline

Posts: 1568



WWW
« Reply #3 on: January 01, 2011, 12:49:12 PM »

Robbi Williams......äh..Take That......äh..use this 

my english ist not well because i find die wörter net so schnell..  grin
Logged

Signatur wird geladen...
dbs
WebsiteBaker Org e.V.

Offline Offline

Posts: 3719


WWW
« Reply #4 on: January 01, 2011, 01:42:48 PM »

thx for share, no problems with jQA, works well wink
Logged

PurpleEdge

Offline Offline

Posts: 232



WWW
« Reply #5 on: January 02, 2011, 05:42:33 AM »

I'm using IE 8.0.6 and the popup doesn't appear in the example link you posted, only the blanked-out screen...

http://www.websitebaker.net/pages/labor/cbsection.php

...works OK in FF.
Logged
dbs
WebsiteBaker Org e.V.

Offline Offline

Posts: 3719


WWW
« Reply #6 on: January 02, 2011, 08:03:08 AM »

yes, you're right, in FF, Opera & Chrome it works well.
f... IE is a problem.
Logged

maverik

Offline Offline

Posts: 1568



WWW
« Reply #7 on: January 02, 2011, 11:01:38 AM »

no problem with IE9 here
Logged

Signatur wird geladen...
maverik

Offline Offline

Posts: 1568



WWW
« Reply #8 on: January 02, 2011, 11:28:56 AM »

please have a look at www.see-canada.de

does this work in ie8 ?

i cant find the mistake, on my site its the same as see-canada.de. on my site it dont work in ie8 on see-canada it works.  huh
« Last Edit: January 02, 2011, 11:41:07 AM by maverik » Logged

Signatur wird geladen...
iradj

Offline Offline

Posts: 261



« Reply #9 on: January 02, 2011, 11:58:37 AM »

On my page also works with IE8 (evgberg.de)

Iradj
Logged
PurpleEdge

Offline Offline

Posts: 232



WWW
« Reply #10 on: January 03, 2011, 12:31:32 AM »

http://www.see-canada.de/ works OK, the other one is still broken on my machine.
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!