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

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?

Observing members: 0 Composing members: 0

1 Answer

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.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther