Sorry, this page is only available in one language

ShowAd

Suggested dropletname: ShowAd

Published by: Dev4me

The ShowAd Droplet takes a (hidden) section from your website and displays it in a sliding advertisement box.
This way it is very simple to show an advertisement on any page of your website.

global $database, $wb;
$get_content = $database->query("SELECT content FROM ".TABLE_PREFIX."mod_wysiwyg WHERE section_id = '$section'");
$fetch_content = $get_content->fetchRow();
$content = ($fetch_content['content']);
$wb->preprocess($content);
$style  = '';
$script  = '<script>';
$script .= 'var timer;var h = -450;var w = 250;var t = 100;';
$script .= 'function startAp(){setLeft();showAp();}';
$script .= 'function hideAp() {if (document.layers) document.layers.pa.visibility = "hide";else if (document.all) document.all.pa.style.visibility = "hidden";else if (document.getElementById) document.getElementById("pa").style.visibility = "hidden";}';
$script .= 'function showAp() {state=typeof tPos;if(state=="undefined") tPos = h;if(tPos < t) {tPos+=25;if(document.layers) document.layers.pa.top = tPos+"px";else if (document.all) document.all.pa.style.top = tPos+"px";else if (document.getElementById) document.getElementById("pa").style.top = tPos+"px";}';
$script .= 'if(timer!=null) clearInterval(timer);timer = setTimeout("showAp()",5);}';
$script .= 'function getoPos() {if (document.layers) alert(document.layers.pa.top);else if (document.all) alert(document.all.pa.style.top);else if (document.getElementById) alert(document.getElementById("pa").style.top);}';
$script .= 'function setLeft() {if (document.layers) document.layers.pa.left = ((window.innerWidth / 2) - (w / 2))+"px";else if (document.all) document.all.pa.style.left = ((document.body.offsetWidth / 2) - (w / 2))+"px";else if (document.getElementById) document.getElementById("pa").style.left = ((window.innerWidth / 2) - (w / 2))+"px";}';
$script .= '</script>';
$page  = '<div id="pa"><div class="pa_close"><a href="javascript:void(0)" onclick="hideAp()">[close]</a></div>';
$page .= $content;
$page .= '</div>';
$start = '<script type="text/javascript">startAp();</script>';
return $style.$script.$page.$start;

usage:

[[showad?section=53]]

The parameter needed is the section id of the (wysiwyg) content you want to use as the advertisement.

How to show the advertisement only once:

Add the code below at the top of the Droplet code:

$cookie = "Droplet_".$section; 
if (isset($_COOKIE[$cookie]))  return ' '; 
setcookie($cookie,
 '1',
 time()+60*60*24*7);

This way it will be shown once per 7 days. (time()+60*60*24*7 = 7 days)



« Previous droplet | Overview | Next droplet »