I added token providing functions to the module

flamingvan - July 7, 2008 - 16:34
Project:Meta tags
Version:5.x-1.9
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I'm using the nodewords_bypath module. The problem with it is that it overrides the meta tags that are entered for specific nodes. To fix this I've added some token providing modules to nodewords.module. The code is below. Will this create any problems? Is it useful?

Thanks,
Moses

<?php
/**
* Implementation of hook_token_values().
*/
function nodewords_token_values($type, $object = NULL, $options = array()) {
  if(
$type = 'node'){
   
$tokens['meta-keywords']      = $object->nodewords['keywords'];
   
$tokens['meta-description']      = $object->nodewords['description'];
    return
$tokens;
  }
  else{
    return;
  }
}

/**
* Implementation of hook_token_list() for Pathauto specific tokens
*/
function nodewords_token_list($type = 'all') {

 
$tokens = array();
  if (
module_exists('nodewords_bypath')) {
    if (
$type == 'node' || $type == 'all') {
     
$tokens['node']['meta-keywords'] = t("The meta keywords");
     
$tokens['node']['meta-description'] = t("The meta description");
    }
  }
  return
$tokens;

}
?>

#1

Robrecht Jacques - July 11, 2008 - 08:32

Why is there:

<?php
 
if (module_exists('nodewords_bypath')) {
?>

Can't the tokens be made available even if nodewords_bypath is not enabled?

Why is there:

<?php
   
if ($type == 'node' || $type == 'all') {
?>

Should something similar not be in nodewords_token_values? I mean: you handle the "all" case here, but not in nodewords_token_values.

Is it possible to always have tokens for all tags? And added to the "global" (or is that "all") token context instead of just "node" context?

#2

Robrecht Jacques - July 11, 2008 - 08:33
Status:active» patch (code needs work)

#3

Robrecht Jacques - July 29, 2008 - 10:27
Status:patch (code needs work)» fixed

Committed. Will be included in the next release of nodewords (5.x-1.10) released later this week.

#4

Anonymous (not verified) - August 12, 2008 - 10:32
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.