0

When i dpm that $vars, in classes key, there is no r_style class, whyyyy? I tried clear cache through devel module, but still the same, what i am doing wrong?

name = JH Template
core = 7.x
engine = phptemplate

styles[all][] = css/style.css
settings[bg_style] = 'r_style'

theme-settings.php

function jh_process_html(&$vars) {
    $vars['classes'] .= ' ' . theme_get_setting('bg_style');
    dpm($vars); // in classes string isn't r_style class
}

EDIT: the real question is, why theme_get_setting('bg_style') returns NULL

SOLVED: that jh_process_html function must be in template.php file, but i don't understand that drupal :D, because that function was executed even in if it was in theme-settings.php, but actually just sometimes and it causes some fails like that theme_get_setting returned null. I don't know why this happened, but it's really funny after so many years of development of drupal, this magic happened.

3
  • Why do you expect that to work? Where is the rest of your code?
    – Alex Gill
    Commented Feb 25, 2014 at 15:07
  • @AlexGill: pleas check again the code, i added one line, where i use dpm
    – Krab
    Commented Feb 25, 2014 at 15:09
  • Use template_preprocess_html(), see answer.
    – Alex Gill
    Commented Feb 25, 2014 at 15:14

1 Answer 1

1

Try this...

function jh_preprocess_html(&$vars) {
$vars['classes_array'][] = theme_get_setting('bg_style');
}

You need to do this at an earlier stage of the processing.

2
  • After dpm, i see in classes_array is one NULL item, that is because theme_get_setting('bg_style') gives me NULL. This is where the problem is.
    – Krab
    Commented Feb 25, 2014 at 15:15
  • Some sort of caching going on there probably...
    – Alex Gill
    Commented Feb 25, 2014 at 15:17

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.