I'm new to both Drupal and the Advertisement module - so far so good!

I've encountered one problem though. I created an image ad and used a standard block to display it, however the ad didn't appear using the Javascript display method, but it did using the Raw method. With the Javascript method the page source contains:

<div class="advertisement" id="group-tids-6"><script type="text/javascript" src="http://localhost/drupal/sites/all/modules/ad/serve.php?q=1&amp;t=6"></script></div>

and the output is:

<br />
<b>Notice</b>:  Use of undefined constant DRUPAL_ROOT - assumed 'DRUPAL_ROOT' in <b>C:\www\webapps\drupal\sites\all\modules\ad\adserve.inc</b> on line <b>439</b><br />
<br />
<b>Notice</b>:  Use of undefined constant DRUPAL_ROOT - assumed 'DRUPAL_ROOT' in <b>C:\www\webapps\drupal\sites\all\modules\ad\adserve.inc</b> on line <b>439</b><br />
<br />
<b>Notice</b>:  Use of undefined constant DRUPAL_ROOT - assumed 'DRUPAL_ROOT' in <b>C:\www\webapps\drupal\sites\all\modules\ad\adserve.inc</b> on line <b>443</b><br />
<br />
<b>Notice</b>:  Use of undefined constant DRUPAL_ROOT - assumed 'DRUPAL_ROOT' in <b>C:\www\webapps\drupal\sites\all\modules\ad\adserve.inc</b> on line <b>443</b><br />
document.write('\x3c!-- No active ads were found in the tids \'0\'. --\x3e');

Any ideas?

I'd prefer to use Javascript to ensure clicks are tracked even when the cache is on.

CommentFileSizeAuthor
#2 DRUPAL_ROOT.patch817 bytesGarrett Albright

Comments

mnapier’s picture

If you haven't already done so, go back and follow the INSTALL.txt file in the documentation directory. specifically this note;

NOTE: You can optionally set the DRUPAL_ROOT variable at the top of the
adserve.inc file. The ad module tries to automatically find the root
Drupal directory, but it will fail if you use symbolic links in your
installation.

Garrett Albright’s picture

Title: Image ad shows in Raw mode but not in Javascript » Undefined constant used in adserve.inc
Category: support » bug
Status: Active » Needs review
StatusFileSize
new817 bytes

Regardless of what INSTALL.txt says, if the definition of a constant is optional, it is an error to try to use that constant without checking for its existence first. The code does that, but not in a clean manner that will work for those of us who code PHP with full error reporting turned on (which, sadly, few people do, which is probably why this error did not become apparent sooner). Here's a patch.

jeremy’s picture

Status: Needs review » Fixed

Thanks, fixed in the development branch.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.