How to render the textfield from custom advanced theme setting? I'm working on a custom theme with message field(textfield) in custom advanced theme setting.

In "theme-settings.php", I added a "textfield" for "message" field

&lt;?php
function MYTHEME_form_system_theme_settings_alter(&amp;$form, $form_state) {
    $form['message_value'] = array(
        '#type'     =&gt; 'textfield',
        '#size' =&gt; 12,
        '#maxlength' =&gt; 100,
        '#default_value' =&gt; theme_get_setting('message_value'),
        '#description' =&gt; t('Some text here'),
    );
}
?&gt;


In "template.php", I added "theme_get_setting"

&lt;?php
  function MYTHEME_preprocess_page(&amp;$vars) {
    $message = theme_get_setting('message_value');
  }


And in my "page.tpl.php", I render the "message" if it is not empty

&lt;?php if(!empty($message)) echo $message; ?&gt;


The problem is, it does not render anything and has no error.

It works if I put the theme_get_setting in page.tpl.php

&lt;?php $message = theme_get_setting('message_value'); ?&gt;


How to make it work if I want to put that in "template.php"?
In your template.php preprocess function, you need to pass the message back as a key/value in the variables array. (I set the variable key as "custom_msg" as "message" may be too generic and be accidentally confused with any system message variables"

function MYTHEME_preprocess_page(&amp;$vars) {
    $message = theme_get_setting('message_value');
    $vars['custom_msg'] = $message;
}


Then, in your page.tpl.php, the variable would be accessible as $custom_msg (or whatever custom key you set in the preprocess function) and can be included in your page template as:

&lt;?php if(!empty($custom_msg)) echo $custom_msg; ?&gt;


More information about this can be found on this Drupal.org page: Setting up variables for use in a template (preprocess and process functions)