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 |
Jump to:
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
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
Yes, input filter has been enabled to evaluate php.
echo arg(0) yields 1.
#3
How about "echo $_GET['q'];"? Perhaps you'll need to emulate arg() from path.inc?
#4
Still getting 1.
#5
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
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
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
Automatically closed -- issue fixed for 2 weeks with no activity.