How to figure out the node id of the page from inside ad html

kayceedub - June 24, 2009 - 20:53
Project:Advertisement
Version:6.x-2.0
Component:ad_embed module
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I wasn't able to find anything in the issues or out on the web on this.

I need to pull in the node id of the page into the ad html in order to make the ad html display the right information. The ad html accepts and evaluates php. But when i put in something like:

if ( arg(0) == 'node' && is_numeric(arg(1)) && ! arg(2) ) {
$nid = arg(1)
}

It doesn't seem to be able to find the args. What am i missing?

thanks!
I

#1

Jeremy - July 6, 2009 - 23:04
Status:active» postponed (maintainer needs more info)

When you say that the ad_html module evaulates PHP, I assume you have enabled an input filter to make this possible?

Have you tried just doing an "echo arg(0)" in your code to see what it's returning at this point in the code?

#2

kayceedub - July 7, 2009 - 18:07

Yes, input filter has been enabled to evaluate php.

echo arg(0) yields 1.

#3

Jeremy - July 29, 2009 - 22:51

How about "echo $_GET['q'];"? Perhaps you'll need to emulate arg() from path.inc?

#4

kayceedub - August 10, 2009 - 15:51

Still getting 1.

#5

Jeremy - August 10, 2009 - 16:55

When are you seeing this? While saving the node, or when the node is actually displayed. If $q == 1, then you're seeing this when displaying nodes, when $q is actually used to specify quantity. In this case try instead looking at $_GET['u'] -- does that give you what you need?

#6

kayceedub - August 10, 2009 - 17:31
Status:postponed (maintainer needs more info)» closed

Thanks! I just figured that same thing out myself.

In the ad, I put in echo $_SERVER["REQUEST_URI"]; just to see what it thinks uri was when the ad is being displayed within a node and got back:
/sites/all/modules/ad/serve.php?q=1&t=26&u=node/4230

So I tried $_GET['u'] and that works. Thanks again! Great module!

#7

Jeremy - August 10, 2009 - 17:33
Status:closed» fixed

Moving into "fixed" status so other people can easily find this issue if they're trying to do something similar. It will auto-close after 2 weeks.

#8

System Message - August 24, 2009 - 17:40
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.