9

Is there any module or some configuration that I can define the meta tags for the views page display in drupal 7 using Views 3.0?

closed as off-topic by kiamlaluno Jul 27 '16 at 18:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking to recommend or find a book, tool, module, theme, distribution, tutorial, or other off-site resource are off-topic for Drupal Answers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – kiamlaluno
If this question can be reworded to fit the rules in the help center, please edit the question.

8

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!).

  • Nice, I was using the 1.9 version. This feature for tagging a page based on the url is only on 2.0 beta version. Thanks. – Luiz Guilherme Jul 23 '11 at 13:24
  • For me it was a "Path-Based Metatags" titled tab on the page itself (frontend). Also had to make sure render($tabs) was printed in page.tpl.php. – leymannx Apr 27 '15 at 12:35
12

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).

  • 2
    Surprised this answer isn't getting more love... If you're using the metatags module then just install the metatags_views submodule and you'll get metatag options in the views UI for any views page display. – Paul Querol Apr 27 '15 at 16:31
  • Agree. But the answer above was in 2011. There was no metatags_views submodule at that time. You can add the text about metatags_views submodule into my answer if you want. – milkovsky Apr 28 '15 at 8:15
1

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');
    }
  }
}
-1

Most straight forward solution is to add the view as a block inside a node, and then use module like Metatag to place metatags on the node.

Avoids the views integration issue. Also provides benefit of breadcrumbs, menus, pathauto, etc. all easier to set up when page is a node rather than a view.

  • Downvote as I don't see this as being feasible in many cases, such as a site which has a few contextual arguments on a view, and the meta needs to differ for different view arguments. – Phizes Mar 23 '13 at 18:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.