Author Topic: [*droplet*] colorBoxOnLoad (Pop up your Ad)  (Read 9591 times)

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
[*droplet*] colorBoxOnLoad (Pop up your Ad)
« 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) [Select]
<?php 
global $database$wb;

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

$cookie "sID_".$sID;

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

$section_id intval($sID); // [!]variable needed for the included file 
        
ob_start();        
        require(
WB_PATH.&#39;/modules/&#39;.$module_check.&#39;/view.php&#39;);
        // here is our content within two divs, one is hidden via style definition
        
$output .= &#39;<div style="display:none;"><div id="colorbox_section">&#39;.ob_get_contents().&#39;</div></div>&#39;;
        
ob_end_clean();            
    } else 
    
// if requested Section doesn&#39;t exist
    
$output .= "<p>The requested section wasn&#39;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 () {
$(&#39;.cboxOnLoad&#39;).colorbox({
inline: true, 
href: &#39;#colorbox_section&#39;,
innerWidth:
$width
innerHeight:
$height,
maxWidth: "98%",
maxHeight: "98%",
});
$(&#39;a.cboxOnLoad&#39;).click();
 
});
/* ]]> */
</script>
_SCRIPT;

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

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


?>



Kind Regards,
Stefek


« Last Edit: December 30, 2010, 05:46:14 AM by Stefek »
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline iradj

  • Posts: 353
  • Gender: Male
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« 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

Offline dbs

  • Betatester
  • **
  • Posts: 8075
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« Reply #2 on: January 01, 2011, 12:36:27 PM »
hi, have you a zip of the droplet, for import?

Offline maverik

  • Posts: 1572
  • Gender: Male
  • ..:: viva los tioz ::..
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« Reply #3 on: January 01, 2011, 12:49:12 PM »
Robbi Williams......äh..T ake That......äh..use this 

my english ist not well because i find die wörter net so schnell..  :-D

[gelöscht durch Administrator]

Offline dbs

  • Betatester
  • **
  • Posts: 8075
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« Reply #4 on: January 01, 2011, 01:42:48 PM »
thx for share, no problems with jQA, works well ;-)

Offline PurpleEdge

  • Posts: 231
  • Gender: Male
    • the northern beaches
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« 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.

Offline dbs

  • Betatester
  • **
  • Posts: 8075
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« 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.

Offline maverik

  • Posts: 1572
  • Gender: Male
  • ..:: viva los tioz ::..
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« Reply #7 on: January 02, 2011, 11:01:38 AM »
no problem with IE9 here

Offline maverik

  • Posts: 1572
  • Gender: Male
  • ..:: viva los tioz ::..
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« 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.  :?
« Last Edit: January 02, 2011, 11:41:07 AM by maverik »

Offline iradj

  • Posts: 353
  • Gender: Male
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« Reply #9 on: January 02, 2011, 11:58:37 AM »
On my page also works with IE8 (evgberg.de)

Iradj

Offline PurpleEdge

  • Posts: 231
  • Gender: Male
    • the northern beaches
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« 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.

Offline Tomno399

  • Posts: 211
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« Reply #11 on: August 30, 2015, 07:35:23 PM »
WB283 SP4; PHP 5.5

Das Droplet zeigt schon beim Speichern einen Fehler (roter Tropfen). Eine Syntaxprüfung des Codes ergab "Parse error: syntax error, unexpected 'else' (T_ELSE) in /in/eeLmI on line 7". Komisch, dass der Fehler schon ab PHP 4 und jetzt bis PHP 5.6. angezeigt wird.
Hat jemand dafür eine Lösung?

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« Reply #12 on: August 30, 2015, 07:42:55 PM »
Hallo,

schau mal so:

DROPLETS CODE:
Code: (ColorboxOnLoad) [Select]
<?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;
?>


Das Droplet ist alt, da habe ich grad meine ersten Gehversuche mit PHP gemacht ;-)

Schönen Gruß,
Stefek
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline Tomno399

  • Posts: 211
Re: [*droplet*] colorBoxOnLoad (Pop up your Ad)
« Reply #13 on: August 31, 2015, 11:09:34 AM »
Sorry, now I realize that I have written in German Language in an English thread.

Stefek, many thanks to you. The droplet works with the colorbox-plugin http://jquery.lepton-cms.org/plugins/lightbox-effects/jq-colorbox.php and the jQuery 1.32).

A newer plugin, which would work with jQuery >1.9 I couldn't find. Yeah, we have to practice patience.

Thank you Stefek!

 

postern-length