I suppose that project()
is a page callback, a function that is associated to a path used from the module, and that needs to output what contained in $body
. In that case, you need to returns its content, and your code should be like the following one.
function project() {
global $user;
$uid = $user->uid;
$name = $user->name;
// The rest of your code.
return '<script language="JavaScript" src="/misc/collapse.js" type="text/javascript"></script>' . "<div><p>Projects from user $name</p></div>";
}
The reason is that drupal_deliver_html_page() (indirectly called from index.php) contains the following code.
if (is_int($page_callback_result)) {
// The page callback returned an integer.
// …
elseif (isset($page_callback_result)) {
// The page callback returned a string or an array.
// Print anything besides a menu constant, assuming it's not NULL or
// undefined.
print drupal_render_page($page_callback_result);
}
If your page callback doesn't return anything, but it just prints its own output, drupal_render_page()
will not be called, and the output of your page callback will be all the content you see in the page.