function cpn_page_build in Code per Node 7
Implements hook_page_build().
File
- ./
cpn.module, line 42 - Primary hook implementations.
Code
function cpn_page_build(&$page) {
// Optional weights.
$weight = array(
'css' => variable_get('cpn_weight_css', CSS_THEME),
'js' => variable_get('cpn_weight_js', JS_THEME),
);
foreach (array(
'css',
'js',
) as $type) {
// Only proceed if the 'agree' option was checked and if some code was
// actually saved.
$agree = variable_get('cpn_global_' . $type . '_agree', FALSE);
$code = variable_get('cpn_global_' . $type, '');
if ($agree && !empty($code)) {
// Only proceed if either this is not an admin page or if the 'load on
// admin pages too' option was checked.
$page_is_admin = path_is_admin(current_path());
$force_on_admin = (bool) variable_get('cpn_global_' . $type . '_admin', FALSE);
if (!$page_is_admin || $force_on_admin) {
$file = variable_get('cpn_path', 'public://cpn') . '/global.' . $type;
$page['content']['#attached'][$type]['cpn_global'] = array(
'type' => 'file',
'group' => $type == 'css' ? CSS_THEME : JS_THEME,
'weight' => $weight[$type] - 2,
'data' => $file,
'preprocess' => (bool) variable_get('cpn_aggregation_' . $type, FALSE),
);
}
}
}
}