How to access/print fields in non-Drupal php files? I'm using Drupal's php filter to add php code in node body of some of my nodes. Among other things, I'm also including a php file. That php file is doing some non-Drupal work and it is included in those nodes properly. However, I can't print Drupal's fields in that file.

Here is an example of php code in node's body field:

&lt;?php

some work is happening here

include 'non-drupal.php'; // include non-drupal php file

some work is happening here

?&gt;


Here is an example of non-drupal.php:

&lt;?php

echo date('h:i:s'); // This works

print $title; // This doesn't work

?&gt;


When I open that node, I can see the time, but there's no node title displayed.

Is it possible to print node fields from "external" php files?

EDIT (code added from dropbucket) I have tried with adding this code from Dropbucket, but it's not working either):

&lt;?php

echo date('h:i:s'); // This works

function get_node_title($nid) {
return db_query('SELECT title FROM {node} WHERE nid = :nid', array(':nid' =&gt; $nid))-&gt;fetchField();
} // This doesn't work (There is no output, but no errors displayed either)

?&gt;
You could try it with drupal_bootstrap, but it is not tested.

define('DRUPAL_ROOT', '/path/to/drupal');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$title = drupal_get_title();
echo $title;