Hello,
I am using Nodewords 6.x-1.11 together with Nodewords Node Type at the moment.
As 6.x-1.12 Beta 9 finally has token replacement, I am interested in updating to that version and deinstall Nodewords Node Type. So I tested the new version today...

It generally works, but the token replacement list in the custom pages area is missing lots of tokens (compared to the list offered in Nodewords Node Type). For example, there are no “CCK text” or “Location“ Tokens. Of course, these tokens are not only missing in that list, but they are not replaced either. As I use these tokens very much in my metatags keywords and descriptions, this is a big problem for me.

Will these Tokens be supported in the future? Or is there a patch available that makes Beta 9 handle these tokens?

Thanks.

Comments

Druppy-dupe’s picture

I have the same problem:

I use custom pages meta tags to create meta tags for all nodes in the path news/*.

Only the global tokens are replaced at the moment. All node-based tokens are not working and are not in the replacement list.

This should be changed as soon as possible.

Anonymous’s picture

Actually, there is a wrong call to theme('token_help') in the other module.
Without giving a value for $type, the theme function will consider the value 'all', which means the list of tokens will include all the tokens, even the ones that the module will not use because it calls token_replace() passing a node as object.

summit’s picture

Subscribing, would love to see the arg() tokens also supported!
greetings,
Martijn

Anonymous’s picture

Subscribing, would love to see the arg() tokens also supported!

If those tokens are added as global tokens, then Nodewords is able to use them. If they are added as a category apart (I mean different from the usual categories like node, user, etc), then Nodewords cannot use them, with the actual code.

Brian294’s picture

StatusFileSize
new6.83 KB
new844 bytes

This patch doesn't work; see what reported in comment #7.

I have attached the .patch and nodewords.module (zipped) using the -dev version dated 6/15. This also addresses the feature request #837108 (http://drupal.org/node/837108) to provide better token integration with the nodewords_pagetitle module.

Brian294’s picture

Status: Active » Needs review
StatusFileSize
new6.64 KB

The code contained in this archive doesn't work as expected; see comment #7.

For anyone using beta9, here is the nodewords.module file you can use that will give you more token options for your custom pages.

Anonymous’s picture

Status: Needs review » Needs work

The patch in #5 is not in the correct format; see http://drupal.org/patch/create to understand how a patch is created.

The code as changed from the patch doesn't work.
In the case of custom pages, $options['id'] is not a user ID, nor a node ID; the calls to _nodewords_node_load($options), and user_load($options['id']) would return a random node, and a random user object that are not related with the page being viewed.

Brian294’s picture

Yes, you're correct with all of those observations. A perfect patch would need to take into consideration the type of path being accessed and then make sure only the relevant tokens are being loaded. This patch makes the assumption that the person creating the custom page knows which tokens are appropriate. For example, I would never use the user tokens if I am building a custom page for a node.

I'll give some more thought into how to address this issue.

Brian294’s picture

Status: Needs work » Needs review
StatusFileSize
new6.89 KB

kiam,
Here is the revised code that will address the issue. I unfortunately could not create a cvs patch because the "HEAD" for nodewords appears to be radically different from the current -dev version. Perhaps I'm doing cvs wrong. Let me know which tag I should be using in CVS for patching.

Anyway, review the code starting a line 589 to see how I address the token loading issue.

Peace,
Brian

Brian294’s picture

StatusFileSize
new1.7 KB

I think I figured it out! DRUPAL-6--1 should be used, yes? Here is the patch.

Anonymous’s picture

Status: Needs review » Needs work

The patch is still using $options, but for custom pages that array doesn't contain any node ID, nor user ID.

Brian294’s picture

kiam, I think this is because of a bug in how custom pages are handled in -dev. See:

http://drupal.org/node/835158#comment-3142624

Arguments are not returning correctly because the following file and function are missing:
nodewords_custom_pages\includes\nodewords_custom_pages.nodewords.hooks.inc
-> nodewords_custom_pages_nodewords_type_id()

Brian294’s picture

Status: Needs work » Needs review
Anonymous’s picture

Status: Needs review » Needs work

For some strange reason, the file has been removed from CVS, but it was still present in my local repository from where I commit the code. Thanks for pointing out that.

As per the patch, it is not correct yet. Let me see if I make myself clear.

The array $options returned by the module nodewords_custom_pages.module contains information about the custom page; in particular, $options['id'] is the identifier associated with the custom page, the same value that is saved in the module table.

  1. It is not a node ID; passing it to node_load() doesn't make sense.
  2. It is not a user ID; passing it to user_load() doesn't make sense.
  3. It is not a taxonomy term ID; passing it to any function that expects a taxonomy term ID doesn't make any sense.
+	  if (arg(0) == 'node') {
+		$token_objects['node'] = _nodewords_node_load($options);
+		$token_objects['node meta tags'] = $token_objects['node'];
+	  }
+	  if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
+		$token_objects['taxonomy'] = _nodewords_taxonomy_object_load($options);
+	  }
+	  if (arg(0) == 'user') {
+		$token_objects['user'] = user_load($options['id']);
+	  }

I hope it's clear what I mean.

Anonymous’s picture

To be sure to be clear enough, I will make an example.

  1. You just installed Nodewords; you didn't have it installed before, and the database doesn't contain any data saved from the module.
  2. You enable the Meta tags for custom pages module, together with the Basic meta tags module, and the Administration interface for Nodewords module.
  3. You define a rule for custom pages, associating it to the path node/* (it's perfectly possible, and allowed — that is the reason nodewords_custom_pages.module has a weight that is lower that 0). As it's the first rule created, its ID will be probably 1.
  4. You visit the page http://example.com/node/16 (I take the supposition that a node with that ID exists). Nodewords will find that the saved rule applies, and will return its data.
  5. Your patch uses the custom page ID as node ID, but it would get back the object for the node with ID 1, while the viewed node has ID 16. In other words, it returns the data for a node that is not even viewed; is there any logic?
  6. Your patch get the data for the user with ID 1, when the viewed page is a node page. What is the relation between the user with ID 1, and the node with ID 16? Probably it could be the author of the node, but it's rather difficult that the ID of the author of a node is equal to the ID used for the rule being applied; it is also difficult that the user #1 is always the author of all the nodes published in a Drupal site, if not in the case the user #1 is the only user with permission to create node, which doesn't happen in most of the sites using Drupal.
Brian294’s picture

kiam, you're right. my tests were faulty! grrrr. I will submit a patch to address the issue in dev sometime later tonight.

Brian294’s picture

StatusFileSize
new3.05 KB

I have attached a revised patch that should fix the issue. It also takes into consideration other arg(0) parameters that I previously overlooked. Patch is for latest -dev release.

Brian294’s picture

Status: Needs work » Needs review
rjbrown99’s picture

#17 worked for me on the latest dev. Cleanly applied, tokens show up, and they work. Thanks.

summit’s picture

#17 worked for me also.
greetings, Martijn

wxman’s picture

#17 worked for me. Of course I had already torn all my hair out trying to find a workaround before I read all this. I'm using Pressflow by the way.

Mercury500’s picture

Can somebody please post a nodewords.module patched from #17?

This whole patching thing is crazy. Why not just post the file? Why force everybody to go thru extra hoops to get a few lines changed? Yes, in general, post the patch file for developers, but the changed FILES also.

rjbrown99’s picture

Status: Needs review » Reviewed & tested by the community

#22: Here are directions for applying a patch.
http://drupal.org/patch/apply

If there are bugs, enhancements, or fixes, creating a patch is the standard mechanism to report those changes to the module developer. This is why there are recommended releases vs development releases - if users don't want to hassle over patches, just use the release version of the code. Using the development branches means you also wade into the world of patches and diffs.

I'm also moving this to RTBC because of multiple positive replies.

Mercury500’s picture

Thanks. I know how to apply a patch. It's just grossly inefficient for things like this. there is "getting things done" and there is "playing developer / programmer." I frequently just need to get things done.

And using the recommended releases is frequently NOT an alternative - many, many modules are:

1) use dev
or
2) use something ancient / unusable / unsupported / un-whatever.

It's not a "choice" to wade into development - you frequently have to use DEV to USE Drupal in any meaningful way.

Sorry, this rant has nothing to do with this nice module.

It's the patch mentality. The patch system is needed and and useful, but why force everybody to rebuild something already built? E.g. I could have used this file in seconds. Seconds. Instead, it's going to take 5-15 minutes. It's frequently even faster to manually apply the patch than starting up any patch software.

wxman’s picture

I'm assuming the #17 patch hasn't been committed yet? I just upgraded to the latest dev, and I lost the token again.

damienmckenna’s picture

Issue tags: +v6.x-1.12 blocker

Tagging.

Brian294’s picture

Agreed! :-)

damienmckenna’s picture

StatusFileSize
new3.37 KB

Re-rolled against the latest CVS and resolved some coding standards violations (tabs, incorrect nesting).

damienmckenna’s picture

StatusFileSize
new3.61 KB

Added some additional comments, more for our own benefit.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, nodewords-n781440-29.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review

Re-queuing.

damienmckenna’s picture

StatusFileSize
new3.61 KB

Included the patch this time.

damienmckenna’s picture

Version: 6.x-1.12-beta9 » 6.x-1.x-dev
StatusFileSize
new3.61 KB

I'll eventually work out how to do patch queuing properly.

damienmckenna’s picture

damienmckenna’s picture

Status: Needs review » Fixed
dave reid’s picture

Priority: Normal » Major
Status: Fixed » Needs work

This patch caused a metric load of PHP notices now when viewing a node page:

Notice: Undefined index: id in _nodewords_node_load() (line 953 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/nodewords/nodewords.module).
Notice: Trying to get property of non-object in node_token_values() (line 25 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 28 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 32 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 33 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 34 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Undefined variable: type in node_get_types() (line 450 of /home/davereid/Dropbox/Projects/drupal6dev/modules/node/node.module).
Notice: Trying to get property of non-object in node_token_values() (line 35 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 36 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 37 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 38 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 40 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 41 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 52 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 68 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Undefined variable: type in uc_product_is_product() (line 1686 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/ubercart/uc_product/uc_product.module).
Notice: Trying to get property of non-object in _pathauto_token_values() (line 61 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/pathauto/pathauto.tokens.inc).
Notice: Trying to get property of non-object in project_token_values() (line 1485 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/project/project.module).
Notice: Trying to get property of non-object in _nodewords_tokens_metatag_from_node_content() (line 249 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/nodewords/nodewords_tokens/nodewords_tokens.module).
Notice: Trying to get property of non-object in _nodewords_tokens_metatag_from_node_content() (line 272 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/nodewords/nodewords_tokens/nodewords_tokens.module).
Notice: Trying to get property of non-object in _nodewords_tokens_metatag_from_node_content() (line 297 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/nodewords/nodewords_tokens/nodewords_tokens.module).
Notice: Trying to get property of non-object in taxonomy_node_get_terms() (line 632 of /home/davereid/Dropbox/Projects/drupal6dev/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in taxonomy_node_get_terms() (line 633 of /home/davereid/Dropbox/Projects/drupal6dev/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in taxonomy_node_get_terms() (line 634 of /home/davereid/Dropbox/Projects/drupal6dev/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in taxonomy_node_get_terms() (line 639 of /home/davereid/Dropbox/Projects/drupal6dev/modules/taxonomy/taxonomy.module).
Notice: Undefined index: id in _nodewords_node_load() (line 953 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/nodewords/nodewords.module).
Notice: Trying to get property of non-object in node_token_values() (line 25 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 28 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 32 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 33 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 34 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Undefined variable: type in node_get_types() (line 450 of /home/davereid/Dropbox/Projects/drupal6dev/modules/node/node.module).
Notice: Trying to get property of non-object in node_token_values() (line 35 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 36 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 37 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 38 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 40 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 41 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 52 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 68 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Undefined variable: type in uc_product_is_product() (line 1686 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/ubercart/uc_product/uc_product.module).
Notice: Trying to get property of non-object in _pathauto_token_values() (line 61 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/pathauto/pathauto.tokens.inc).
Notice: Trying to get property of non-object in project_token_values() (line 1485 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/project/project.module).
Notice: Undefined index: id in _nodewords_node_load() (line 953 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/nodewords/nodewords.module).
Notice: Trying to get property of non-object in node_token_values() (line 25 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 28 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 32 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 33 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 34 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Undefined variable: type in node_get_types() (line 450 of /home/davereid/Dropbox/Projects/drupal6dev/modules/node/node.module).
Notice: Trying to get property of non-object in node_token_values() (line 35 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 36 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 37 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 38 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 40 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 41 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 52 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Trying to get property of non-object in node_token_values() (line 68 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/token/token_node.inc).
Notice: Undefined variable: type in uc_product_is_product() (line 1686 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/ubercart/uc_product/uc_product.module).
Notice: Trying to get property of non-object in _pathauto_token_values() (line 61 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/pathauto/pathauto.tokens.inc).
Notice: Trying to get property of non-object in project_token_values() (line 1485 of /home/davereid/Dropbox/Projects/drupal6dev/sites/all/modules/project/project.module).
dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new9.69 KB

Follow-up patch to fix all the notices and cleanup the $arg and global token logic. Tested with all PHP error reporting settings enabled, and I don't get any notices anymore.

damienmckenna’s picture

Status: Needs review » Fixed

Apologies for missing that, and thanks for fixing it. The patch looks good. Committed.

dave reid’s picture

Status: Fixed » Needs review
StatusFileSize
new10.15 KB

Another follow-up. :)

Also discovered tonight there is a waaaaay better way to support finding the current token context without the giant switch statement by just letting the implementations of hook_nodewords_type_id() alter the context if they have decided they should. That way if we do have the context changed, we can just drop down to the basic set of token type loaders.

Also found that the user_nodewords_type_id() function was misnamed user_metatags_type(), so it currently fails. Added contexts for blogs and trackers, as well as improved the context detection for nodes and user pages. And the token code called the forum function for the uc_catalog switch case...another completely broken section of code.

This also has the benefit of removing the completely unnecessary _nodewords_taxonomy_object_load() and _nodewords_node_load() functions.

Brian294’s picture

Dave,
I think this latest round of patches effectively killed nodewords_pagetitle.
http://drupal.org/project/issues/nodewords_pagetitle

Did we remove/rename _nodewords_custom_pages_load_data()?

Peace,
Brian

Brian294’s picture

corrected url of nodewords_pagetitle issue:
http://drupal.org/node/960672

dave reid’s picture

Yes we did, since it was an internal function... I'm on helping patch up nodewords_pagetitle

dave reid’s picture

Status: Needs review » Fixed
msti’s picture

Status: Fixed » Needs review
Issue tags: -v6.x-1.12 blocker

Status: Needs review » Needs work
Issue tags: +v6.x-1.12 blocker

The last submitted patch, 781440-token-replace-context-followup.patch, failed testing.

dave reid’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)
Issue tags: -v6.x-1.12 blocker

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