I'm trying to print out settings from my theme's theme-settings.php into a file called custom.php. Below is the code I'm using in custom.php:

    header("Content-type: text/css; charset: UTF-8");
define('DRUPAL_ROOT', '/path/to/my/drupal/installation');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

body {
    background: url(<?php print (theme_get_setting('theme_custom_background_path')) ?>);

This is what the result is when the page is rendered in the browser:

body {
    background: url();

I'm obviously missing something here -- theme_get_setting isn't working. I'm not sure what kind of code I need to link this file to my theme.

Does anyone know if there is a way to get custom.php to recognize the settings I've defined in my theme's theme-settings.php file with theme_get_setting? I feel like I'm so close but just missing a few lines of code.

At the end of the day if I absolutely need to, I can just print the settings out inline within the head section of html.tpl.php - but I'd much rather include them in a separate stylesheet with the .php extension.

Any suggestions?

  • 1
    Full bootrap Drupal just to pull a theme setting ? Trust me pal you are wasting your server resources.
    – AKS
    Commented Mar 18, 2013 at 19:53

1 Answer 1


Below code worked for me ! Make sure there is a value for setting "theme_custom_background_path" in your theme settings. For example i can able to get logo path of theme using below code

  • Created a file called get_setting.php inside my Drupal Root
  • Copy pasted below code
  • Executed in browser.


define('DRUPAL_ROOT', getcwd());
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
$theme_settings = theme_get_setting('logo');
print "body { background: url(" . $theme_settings . ");}";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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