function om_node_preprocess_page in OM Tools 6
Same name and namespace in other branches
- 8 tools/node/node.inc \om_node_preprocess_page()
- 6.2 tools/node/node.inc \om_node_preprocess_page()
- 7 tools/node/node.inc \om_node_preprocess_page()
Override or insert om variables into the templates.
File
- tools/
node/ node.inc, line 101 - Body Classes Utility
Code
function om_node_preprocess_page(&$vars) {
if (variable_get('om_tools_node_tools_switch', 1)) {
$classes = explode(' ', $vars['body_classes']);
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['node']->type;
if (variable_get('om_tools_node_' . $node_type . '_titles', 0)) {
unset($vars['title']);
$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
}
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 (is_numeric($arg[1]) && is_null($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 || -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
if (!empty($vars['node']->taxonomy) && variable_get('om_tools_node_terms_body_classes', 1)) {
foreach ($vars['node']->taxonomy as $term) {
$classes[] = om_tools_class_safe(variable_get('om_tools_node_terms_body_classes_prefix', 'content-term-') . $term->name);
}
}
}
$classes[] = om_tools_class_safe('section-' . $section);
$classes[] = 'om-tools-active';
}
$vars['body_classes_array'] = $classes;
$vars['body_classes'] = implode(' ', $classes);
// Concatenate with spaces.
//dsm($vars);
}
}