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

wmnnd’s picture

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

What about fixing this issue?

jhaggenburg’s picture

Same here. Any info on this please?

jhaggenburg’s picture

Nevermind, i've fixed this with drupal_set_html_head()

	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.'" />');		
	}
mrfelton’s picture

StatusFileSize
new1.93 KB

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:

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:

mrfelton’s picture

StatusFileSize
new2.31 KB
mrfelton’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
Category: support » bug
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.

avpaderno’s picture

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.

avpaderno’s picture

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.

Status: Fixed » Closed (fixed)

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

powery’s picture

Status: Closed (fixed) » Needs review

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

Anonymous’s picture

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.