function google_admanager_node_view in DFP Small Business (Google Ad Manager) 7.2
Implements hook_node_view().
File
- ./
google_admanager.module, line 208
Code
function google_admanager_node_view($node, $view_mode = 'full') {
if (arg(0) == 'node' && $view_mode == 'full') {
// If we have enabled Node Type attributes, add it
if (variable_get('google_admanager_nodetype_attributes', FALSE)) {
$type = _google_admanager_clean_string($node->type);
google_admanager_add_attribute("node_type", $type);
}
// If we have not enabled any vocabs as attributes, then return from the function as there is nothing more to do.
$enabled_vocabs = variable_get('google_admanager_vocab_attributes', array());
if (count($enabled_vocabs) == 0) {
return;
}
// Load a nodes taxonomy associations from index
$taxonomy = db_query('SELECT * FROM {taxonomy_term_data} LEFT JOIN {taxonomy_index} ON {taxonomy_term_data}.tid = {taxonomy_index}.tid WHERE nid = :nid', array(
':nid' => $node->nid,
));
// If the node has no taxonomy associations there is nothing more to do.
if ($taxonomy
->rowCount() == 0) {
return;
}
// For every term, check if the vocab is enabled and, if so, add as an attribute
foreach ($taxonomy as $tid => $term) {
if (!empty($enabled_vocabs[$term->vid])) {
google_admanager_add_term_attribute($term);
}
}
}
}