Get Template Variables in my Custom Module I am new in drupal. I am trying to get a variable from a template file e.g. maintenance-page.tpl.php and want to get $title variable in a form e.g. admin/config/development/maintenance form. This form will contain a field/textbox to set a custom title and I want to print that custom title on maintenance-page.tpl.php page. How could it be implemented with custom module. I am using Drupal 7. Thanks in Advance.
In Drupal 7 getting global module specific settings or module-site configuration settings is done via:


variable_set



  Sets a persistent variable.



variable_get



  Returns a persistent variable.



variable_del



  Unsets a persistent variable.


This is to be used for global settings which means it is used site-wide. In your use-case it seems appropriate to use.

For your custom form you will get the variable when you build the form, and set the variable in the form's submit handler. If you are using system_settings_form, then the process is even easier as all you have to do is to make sure that your form element for the title is named exactly the same as your persistent variable.  For an example please refer to: How to add a custom admin settings form to accept variable values in Drupal

To print the variable in your template you can either get the variable using variable_get in a preprocess function and set a preprocess variable for it which you then use, or you can just get the variable directly within the template. How do you know which method to use? If the template file is rendered because of a theme function, then there will be a preprocess function for it. But don't break your head to much over this one. Because getting a variable using variable_get is such a small operation, you might as well just do it directly in the template file.