2

I need the variables from the globals.php and I can't seem to call/register them in theme's template.php file. These variables are needed for my custom hook function for the template. Am i missing something (since it's been global and be called somewhere else during rendering)?

  • so far I used global keyword in php, is there something that calls the whole file/module itself and all its settings and variables? – user1076813 Jun 6 '13 at 9:52
  • What's globals.php? Is that a custom file in your project? The way to include files in PHP is with the include function – Clive Jun 6 '13 at 11:28
  • the globals.php i think is included in 7, refer to here api.drupal.org/api/drupal/developer!globals.php/7 , and yes I tried 'include' but I assume that it is included through rendering the page but the scope of the variable is limited – user1076813 Jun 7 '13 at 0:07
  • Ah ok, that's not a physical file just a dev doc that's where I got confused. To access global vars outside the global context (i.e. in a function) you need to 'import' them, e.g. global $user; echo $user->name; – Clive Jun 7 '13 at 0:09
  • ok, yeah thanks for this... i'm trying my best not to mess up the drupal core files so i'm trying to use hooks – user1076813 Jun 7 '13 at 0:13
0

1.in order to include entire file into some other file,we have 2 functions in php:-

a) include('filename'):this function will include the file and if any error occurs during the importing of the file,then the script will not stop and will continue with its execution.

b) require('filename'):this function will include the file and if any error occurs during the importing of the file,then the script will stop.

include() function is recommended for including files.

  • thanks for this, but i'm asking here in a drupal 'way' of including the files, and yes i consider include but I guess drupal already called the file but the variables isn't global in scope, i tried to avoid that since it would be kind of redundant, is there some way to include/load module without calling the file again, just the variables? – user1076813 Jun 7 '13 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.