Drupal - How to define Meta tags on Views?
The Metatag module has views integration from the box since 7.x-1.0-beta2.
Install the metatags_views submodule and you'll get metatag options in the views UI for any views page display (Paul Querol's comment below).
The Meta tags quick module allows you to specify Meta tags based on path for your views. If you enable path-based meta tags, you will see 'Edit meta tags' link on the views page (important - not in the views edit screen!).
If you don't want to use the "Path-Based Metatags" as mentioned earlier you could make the default metatags_quick fields added to the term itself work as desired with the following approach. Here is an example of how I did it with robots and the help of drupal_add_html_head()
:
/**
* Implements hook_preprocess_HOOK()
*/
function MYMODULE_preprocess_page(&$vars) {
// if this is a term page and not being edited
if (arg(1) == 'term' && is_numeric(arg(2)) && is_null(arg(3))) {
// if this is a Views page
$view = (array)views_get_page_view();
if (!empty($view)) {
// if metatags_quick robots are set
$term = taxonomy_term_load(arg(2));
if (isset($term->meta_robots) && !empty($term->meta_robots[LANGUAGE_NONE][0]['metatags_quick']))
$element = array(
'#tag' => 'meta',
'#attributes' => array(
'name' => $term->meta_robots[LANGUAGE_NONE][0]['meta_name'],
'content' => $term->meta_robots[LANGUAGE_NONE][0]['metatags_quick']
),
);
drupal_add_html_head($element, 'MYMODULE');
}
}
}