I would like to create a PHP page that executes Drupal API functions.
The page would be inside my Drupal 7 website, perhaps the theme directory, but I'm not sure where it should reside.
I would like this page to run a query to the database using the Drupal's database abstraction layer. Once the query is retrieved, I would like to run some other D7 API functions and finally print out a page.
The page should not be one of the default Drupal templates, but a new page, that simply has one single within it.
How can I achieve this?
EDIT: The correct way to do this is to implement hook_menu()
inside a module. I'm trying to do this, but my approach doesn't work. This is what I'm doing:
- the profileBox.info file
name = PB description = "Creates a callback to returnuid.tpl.php" package = SDNN core = 7.x files[] = profileBox.module
- the profileBox.module file is installed and has the following code:
function profileBox_menu() {
$items['returnunid'] = array(
'title'=>'Example'
'description'=>'examples'
'page callback' => 'profileBoxGetit',
'access callback'=>TRUE,
);
return $items;
}
function profileBoxGetit() {
$stringit = "the string output";
return $stringit;
}
- I created a returnuid.tpl.php file with some html code in it - just to test (not functional code)
- I then pointed my browser to [root]/?q=returnuid
- I expected to get the content of the
$stringit
variable, but I instead got an "access denied" error
This module actually messes up the Administration menu, which dissapears when the module is installed.
What am I doing wrong?