Download & Extend

Meta tags are not added to all the views

Project:Nodewords: D6 Meta Tags
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

i am using nodewords module..
i have created a website which is having pages generated from view module...
i am able to get the meta tags for my normal static pages but not for the page generated from view module..
wht might be the reason...
need serious help..... pleaseeeee..

Comments

#1

Version:5.x-1.7» 6.x-1.0

What about fixing this issue?

#2

Same here. Any info on this please?

#3

Nevermind, i've fixed this with drupal_set_html_head()

<?php
   
if($node->nodewords["description"]) {
       
$metaDescription = $node->nodewords["description"];    
       
drupal_set_html_head('<meta name="description" content="'.$metaDescription.'" />');
    }
   
    if(
$node->nodewords["keywords"]) {
       
$metaKeywords = $node->nodewords["keywords"];    
       
drupal_set_html_head('<meta name="keywords" content="'.$metaKeywords.'" />');       
    }
?>

#4

I found that the meta tags are set for some views, but not all. I think the problem is due to the fact that the views detection code is run from nodewords_init(), and is based on a direct database query to look for views in the {views_display} table. However, this table doesn't contain information about ALL views, only those that have been manually created. This does not include those views that are provided by other modules.

I fixed this by using nodewords_views_pre_render() to to add nodewords to the page:

<?php
function nodewords_views_pre_render(&$view) {
 
// Don't really do anything with the view. This is just a pretense to insert a breadcrumb.
 
$curpath = $_REQUEST['q'];
 
$curpath = drupal_get_normal_path($curpath);
 
// Check to see if the view path matches the current path.
 
$viewpage = FALSE;
  foreach (
$view->display as $display) {
   
$viewpath = $display->display_options['path'];
   
// if arguments have been passed to the view, include these
   
if ($view->args) {
     
$viewpath .= '/'. join('/', $view->args);
    }
   
$viewpage = $viewpage || ($viewpath == $curpath);
  }
  if (
$viewpage) {
   
$tags = nodewords_get('views', array($view->vid));
    foreach (
$tags as $name => $content) {
      if (!empty(
$content)) {
       
drupal_set_html_head('<meta name="'. $name .'" content="'. $content .'" />');
      }
    }
  }
}
?>

patch attached:

AttachmentSizeStatusTest resultOperations
216262_nodewords_fix_for_views.patch1.93 KBIgnored: Check issue status.NoneNone

#5

AttachmentSizeStatusTest resultOperations
216262_nodewords_fix_for_views.patch2.31 KBIgnored: Check issue status.NoneNone

#6

Version:6.x-1.0» 6.x-1.x-dev
Category:support request» bug report
Status:active» needs review

Damn project.module didn't same my text, tag alterations!!... ^^^ Updated patch for a much more solid views support. Fixes some slopy regex in my previous patch, and works for all kinds of views.

#7

Status:needs review» needs work

The proposed patch contains a call to a third-party module private function (_custom_breadcrumbs_paths_page_match()); Meta tags cannot rely on the presence of a third-party module, not depend from it.
It's then a private function, and we should avoid to call it.

#8

Title:not getting meta tags for the pages generated from view module... using nodewords» Meta tags are not added to all the views
Status:needs work» fixed

I looked at the code of that function, and created a similar function in the project code.
The changes have been committed in CVS.

Thanks for your help.

#9

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#10

Status:closed (fixed)» needs review

There are no metatags on pages generated with views, on front page, on no-node pages.

#11

Status:needs review» closed (fixed)

This is an old issue. As the code is completely different from the one developed one year ago, it is better to open a different issue.