I am creating a module to populate the body of a drupal 7 page of mine.
I have 3 files I am working with.
1. league_settings.module
2. league_settings.js
3. league_settings.php
league_settings.module is as follows.
function league_settings_block_view($delta = '') {
drupal_add_js(drupal_get_path('module', 'league_settings') .'/js/jquery.js');
drupal_add_js(drupal_get_path('module', 'league_settings') .'/js/json2.js');
drupal_add_js(drupal_get_path('module', 'league_settings') .'/js/livequery.js');
drupal_add_js(drupal_get_path('module', 'league_settings') .'/js/leagueSettings.js');
$block = array(
'subject' => t('Enabled Modules'),
'content' => 'this text works',
);
return $block;
}
league_settings.js is simply
$.post('/modules/leage_settings/php/leagueSettings.php',
function(data){
alert(data);
});
league_settings.php is
global $user;
$name = $user->name;
echo $name;
This will alert a black text box. if I echo 'test' it will work properly.
At the moment I am unable to query without getting a error 500 on my post. I have tried throwing global $user in a function to no avail. Is creating a module like this the best way to set up a php/js file to query my drupal database and edit my page html?