Which preprocess hook do I use to fire some HTML altering PHP? I have some PHP that ultimately says 'If this class is present in the HTML, add this string to the $additional_classes array'. Eg, something similar to:

$leftcol_empty = empty($content['leftcol']);
$additional_classes = !$leftcol_empty ? 'medium-8 medium-pull-4' : '';


Currently, I've put this at the top of my .tpl file and it works fine. However, I've been told I should move it to the 'theme preprocess function'.

I looked through my theme's template.php file and tried adding it to my_theme_preprocess_page, my_theme_theme and my_theme_process_html but it stopped working.

I've tried Googling for theme preprocesses but haven't found anything that works.

Would anyone know what preprocesses function I can use here?
you can use theme_preprocess_html(&amp;$variables) OR my_module_preprocess_html(&amp;$variables)

in $variables you will see $variables['classes_array']

if(in_array('class_name', $variables['classes_array'])) {

  //Do your changes

}


Hope this will help.