Meta tags are important in a web site; they permit the webmaster to improve the volume and quality of traffic to a web site from search engines, to target the search for specific keywords.
If you would need to add them to a Drupal 6 powered web site, you could use one of the following:
$op is passed with the value 'load'.
The module I wish to use for my web site should have these features:
All this would be possible in Drupal 6.
menu_get_object() returns the object associated with current path Drupal is showing; by default it returns the node object whose ID is the number returned by arg(1).
Such a module could implement hook_init() in this way:
/** * Implementation of hook_init(). */ function metadata_init() { if ($node = menu_get_object()) { $type_url = str_replace('_', '-', $node->type); $metadata = metadata_get_items(array('type' => $type_url), array('weight' => 'ASC')); foreach ($metadata as $id => $metadatum) { if (($content = $metadatum['content']) != '') { $content = token_replace_multiple($content, array('global' => NULL, 'node' => $node)); drupal_set_html_head('<meta name="'. $metadatum['name'] .'" content="'. check_plain($content) .'" />'); } } } }
and hook_menu() like:
/** * Implementation of hook_menu(). */ function metadata_menu() { foreach (node_get_types('types', NULL, TRUE) as $type) { $type_url = str_replace('_', '-', $type->type); $items["admin/content/node-type/{$type_url}/metadata"] = array( 'title' => 'Metadata', 'page callback' => 'drupal_get_form', 'page arguments' => array('metadata_overview', 3), 'access arguments' => array('administer metadata'), 'weight' => 5, 'type' => MENU_LOCAL_TASK, 'file' => 'metadata.admin.inc', ); $items["admin/content/node-type/{$type_url}/metadata/list"] = array( 'title' => 'List', 'page callback' => 'drupal_get_form', 'page arguments' => array('metadata_overview', 3), 'access arguments' => array('administer metadata'), 'weight' => -1, 'type' => MENU_DEFAULT_LOCAL_TASK, 'file' => 'metadata.admin.inc', ); $items["admin/content/node-type/{$type_url}/metadata/add"] = array( 'title' => 'Add metadata', 'page callback' => 'drupal_get_form', 'page arguments' => array('metadata_edit_form', 3), 'access arguments' => array('administer metadata'), 'type' => MENU_LOCAL_TASK, 'file' => 'metadata.admin.inc', ); } return $items; }
metadata_get_items() would return the list of the meta tags filtered by node types, metadata_overview() would list the metatags defined for the node type, and metadata_edit_form() would present the form to edit the meta tags definition.
Maybe one day I will submit such module to Drupal.
Comments
Re: Drupal and Metatags
For completeness of information, int_meta.module doesn't work on PHP4 because it uses a function that is only present on PHP5 or higher.
Re: Drupal and Metatags
Rather than to implement
hook_init(), it would be preferable to implementhook_nodeapi()which would be garanteed to be called for any nodes (cached or not).In that case, the call to
menu_get_object()would be superfluous.Re: Drupal and Metatags
Integrated Metatags doesn't make any references to PHP5 only functions; actually, it's the only meta tags module which has been updated in the last two months (Meta tags has not been updated since February 15, when the 6.x-1.0-rc1 version has been released).
Comparing the two modules, Integrated Metatags seems more flexible as it allows to create meta tags from the content of one or more CCK fields, which can be combined to create a single meta tag; it doesn't use a fixed list of meta tags, and that makes the module more suitable whenever there is the need to integrate custom metadata in the Drupal output.
At the moment, Meta tags is the more downloaded module: its 6.x-1.0-rc1 usage statistics shows a peak of 6906 on October 5, while the Integrated Metatags project reaches a 123 in the same day (and a peak of 494 on September 28).