General Question

shivian's avatar

How do I use PHP to get the node ID for a block?

Asked by shivian (10points) October 17th, 2007
1 response
“Great Question” (0points)

I am using drupal and trying to write a block using PHP. The block would figure out the node ID for a page (ie: for http://site.com/node/14 it would return “14”) and then put that into another link I’m trying to make using that same number (ie: http://site.com/forward/14). Anyone know how I’d go about doing this?

Topics: , , , ,
Observing members: 0
Composing members: 0

Answers

sferik's avatar

$node is a widely available object in Drupal.

$node->nid will give you the node id of the current node.

Your template could look something like this:

<a href="http://site.com/forward/<?=$node->nid?>">

Answer this question

Login

or

Join

to answer.

Mobile | Desktop


Send Feedback   

`