SimplePortal
Customization => Custom Coding => Topic started by: reverendcolin on March 12, 2009, 10:23:02 AM
-
I'm not a coder and this is probably a stupid question.
How can I add a counter to the advertisements I have in HTML blocks?
I'd rather they didn't show but I would like to know who or what gets hits.
Thanks,
Rev.
-
for a counter, you can simply go to google and search, when you find one, then pop it into a block and have it set for only admin view ;D
-
You can't do that with HTML block, but you can with PHP block. Example codes:
global $scripturl, $modSettings;
if (empty($_GET['wwwRedirect']) || $_GET['wwwRedirect'] != 'ad_redirect')
{
echo '
<div style="text-align: center;"><a href="', $scripturl, '?wwwRedirect=ad_redirect"><img src="http://some.ad/image.here" alt="ad" /></a><br />This ad is clicked ', !empty($modSettings['ad_redirect']) ? $modSettings['ad_redirect'] : 0, ' times.</div>';
}
else
{
updateSettings(array(
'ad_redirect' => !empty($modSettings['ad_redirect']) ? $modSettings['ad_redirect'] + 1 : 1,
));
redirectexit('http://www.where.is/the.ad');
}
I'm hoping that you can modify the code to suit your needs. Click count will be in $modSettings['ad_redirect'].
Moved to the Custom Coding (http://simpleportal.net/index.php?board=39.0) board as this will not be a default feature.