function om_node_preprocess_html in OM Tools 8
Same name and namespace in other branches
- 8.2 tools/node/node.inc \om_node_preprocess_html()
- 7.2 tools/node/node.inc \om_node_preprocess_html()
- 7 tools/node/node.inc \om_node_preprocess_html()
Override or insert om variables into the templates.
File
- tools/
node/ node.inc, line 101 - Body Classes Utility
Code
function om_node_preprocess_html(&$vars) {
if (variable_get('om_tools_node_tools_switch', 0)) {
$classes = $vars['classes_array'];
if (!$vars['is_front']) {
// Add unique class for each page.
$path = drupal_get_path_alias($_GET['q']);
$classes[] = om_tools_class_safe('page-' . $path);
// Add unique class for each website section.
list($section) = explode('/', $path, 2);
$arg = arg();
if ($arg[0] == 'node') {
$node_type = $vars['page']['#type'];
if (variable_get('om_tools_node_' . $node_type . '_titles', 0)) {
$classes[] = 'om-tools-no-title';
}
if (variable_get('om_tools_node_body_classes', 1)) {
if ($arg[1] == 'add' && isset($arg[2])) {
$section = 'node-add';
//section-node-add
$page_type = $arg[2];
//-page
$page_type_op = $arg[2] . '-add';
//-page-add
}
elseif ($arg[1] == 'add' && !isset($arg[2])) {
$section = 'node-add';
//section-node-add
$page_type = 'any';
//-page
$page_type_op = 'any' . '-add';
//-page-add
}
elseif (is_numeric($arg[1]) && !isset($arg[2])) {
$page_type = $node_type;
//-page
$page_type_op = $node_type . '-view';
//-page-view
}
elseif (is_numeric($arg[1]) && $arg[2] != 'edit' && $arg[2] != 'delete') {
$page_type = $node_type;
//-page
$page_type_op = $node_type . '-view';
//-page-view
}
elseif (is_numeric($arg[1]) && ($arg[2] == 'edit' || $arg[2] == 'delete')) {
$section = 'node-' . $arg[2];
//section-node-edit || section-node-delete
$page_type = $node_type;
//-page
$page_type_op = $node_type . '-' . $arg[2];
//-page-edit or -page-delete
}
$classes[] = om_tools_class_safe(variable_get('om_tools_node_body_classes_prefix', 'content-type-') . $page_type);
$classes[] = om_tools_class_safe(variable_get('om_tools_node_body_classes_prefix', 'content-type-') . $page_type_op);
}
// Term classes
is_numeric($arg[1]) ? $terms = om_tools_taxonomy_node_get_terms(node_load($arg[1]), 'tid') : ($terms = '');
if (!empty($terms) && variable_get('om_tools_node_terms_body_classes', 1)) {
foreach ($terms as $term) {
$classes[] = om_tools_class_safe(variable_get('om_tools_node_terms_body_classes_prefix', 'content-term-') . $term->name);
}
}
//dsm($terms);
}
$classes[] = om_tools_class_safe('section-' . $section);
$classes[] = 'om-tools-active';
}
$vars['classes_array'] = $classes;
$vars['classes'] = implode(' ', $classes);
// Concatenate with spaces.
//dsm($vars);
}
}