function nodewords_get in Nodewords: D6 Meta Tags 5
Get the defined meta tags for $type / $id.
Parameters
$type: Realm of the object the meta tags are associated with. This is one of the following: 'node', 'page', 'term', 'vocabulary'.
$ids: Id (or path) of the object to get the meta tags from. This is one of the following:
- 'node' => array of 'nid' of the node
- 'page' => array of 'path' of the displayed page
- 'term' => array of 'tid' of the term
- 'vocabulary' => array of 'vid' of the vocabulary
- 'panels' => array of 'did' of the panel
- 'views' => array of 'vid' of the view
If $type or $ids is not set, an attempt will be made to get it from $_GET['q'].
$filtered: If TRUE, only the meta tags that the user configured for output will be returned. If FALSE, all meta tags will be returned.
Return value
An associative array of the defined meta tags.
2 calls to nodewords_get()
- nodewords_block in ./
nodewords.module - Implementation of hook_block().
- nodewords_menu in ./
nodewords.module - Implementation of hook_menu().
File
- ./
nodewords.module, line 579 - Assign META tags to nodes, vocabularies, terms and pages.
Code
function nodewords_get($type = NULL, $ids = NULL, $filtered = TRUE) {
// Autodetect if $type and/or $ids is not set
if ($type == NULL || $ids == NULL) {
$result = _nodewords_detect_type_and_ids();
$type = $result['type'];
$ids = $result['ids'];
}
if (!is_array($ids)) {
$ids = array(
$ids,
);
}
// Load the values from the database
if (count($ids) == 1 && ($type != 'node' || node_access('view', node_load($ids[0])))) {
$tags = _nodewords_load($type, $ids[0]);
}
else {
$tags = array();
}
// Pages with more than one node/term/vocabulary/...
if ($type == 'term') {
if (isset($tags['keywords'])) {
$terms = array(
$tags['keywords'],
);
}
else {
$terms = array();
}
foreach ($ids as $id) {
$term = taxonomy_get_term($id);
if ($term) {
$terms[] = $term->name;
}
}
if (count($terms)) {
$tags['keywords'] = implode(',', $terms);
}
}
// Prepare tags for output
$tags = _nodewords_prepare($type, $ids, $tags, $filtered);
return $tags;
}