Closed (won't fix)
Project:
Nodewords: D6 Meta Tags
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
25 Jan 2008 at 19:56 UTC
Updated:
9 Oct 2009 at 08:33 UTC
Reading a bit more about the new menu system I think following piece of code shows the probably desired future direction of this module:
// $Id$
/**
* Implementation of hook_init().
*/
function nodewords_init() {
$item = menu_get_item();
if ($item['access']) {
switch ($item['path']) {
case 'node/%':
// This adds the tags for node pages (note the support for tokens).
$tags = array(
'DC.title' => '[title] - [site-name]',
'description' => '[body]', //TODO: [body] is not a token
);
if ($node = menu_get_object('node', 1)) {
$tags = token_replace($tags, 'node', $node);
foreach ($tags as $key => $value) {
drupal_set_html_head('<meta name="'. $key .'" content="'. $value .'" />');
}
}
break;
// A similar portion would appear for other special
// pages we handle, eg panels, views, taxonomy, ...
default:
// Here we would add the tags that appear on every
// page.
}
}
else {
// Here we could add tags that people want to see on
// "Access denied" pages or "Page not found" pages.
drupal_set_html_head('<meta name="robots" content="noarchive,nofollow,nocache,noindex" />');
}
}
This gets rid of the nodewords_get_type_and_ids() because the menu system more or less gives that for free.
This is just proof-of-concept. I'll need to investigate whether the other special pages we support can be handled this way too. Panels doesn't have a D6 branch yet and at first glance, views is not as easy as views/%view_id.
Still, I think we could have winner here...
Comments
Comment #1
Robrecht Jacques commentedComment #2
avpadernohook_init()is only called for not cached pages; this means the module would not set the meta tags for already cached pages (which is not desired).Comment #3
avpadernoBranch 6.x-2 has never been supported, and it is not anymore developed.