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:
<?php
some work is happening here
include 'non-drupal.php'; // include non-drupal php file
some work is happening here
?>
Here is an example of non-drupal.php:
<?php
echo date('h:i:s'); // This works
print $title; // This doesn't work
?>
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):
<?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' => $nid))->fetchField();
} // This doesn't work (There is no output, but no errors displayed either)
?>