I'm using a rule and [node:node-path] does not display the auto alias path (using pathauto). Instead it returns node/xxx...

the weight of pathauto is 1
the weight of Token module is 10
the wright of Rules module is 20

what could be wrong?
thank you

Comments

itangalo’s picture

Component: Rules Core » Rules Engine
Status: Active » Postponed (maintainer needs more info)

Does your rule run at the node save moment, or after the node has been saved?
If it is during the save moment, new nodes probably won't have any URL alias associated with them yet.

Could this be the case?
//Johan Falk
I'm a part of the Rules Issue Squad, helping out in the issue queue. You can join, too!

hedac’s picture

thank you for your answer.
Yes. It is "ON event After saving new content"

itangalo’s picture

Hah! I read and re-read the issue above. And then I realized that "[node:node-path]" really suggests that it is returning the path for the node – not the URL alias.

Does the replacement descriptions really say that it should return the alias for the node, or is this a case of not-so-clear help text?

hedac’s picture

in the Token replacement patterns in the rule action I see "[node:node-path] The URL alias of the node." so yes it says it should return the URL Alias.
there is another token which is [node:node-url] but this is not the alias.

so I create a node and pathauto assigns the node automatically an alias, but in the rules action it doesn't seem to get that alias.. instead it returns the node/xxxx path... where xxx is the number of the node...

but thinking it twice.. maybe this is an issue of token module and not rules.

itangalo’s picture

Hm, yeah, it is most likely a Token thing and not Rules.

You could try using the other token (node:node-url), and see if there has just been some intermixing. It would still be a bug to report, though.

Thanks for your patience.
I would have changed the project for this isssue to Token, but I don't know which version you're using…

mhindman’s picture

I was having this same issue and found a workaround. Thought I would share for anyone else encountering the same issue.

  1. Add a new "Load content by id" action.
  2. Load the current node by adding [node:nid] to the Content ID field.
  3. Give it a recognizable/appropriate label and variable name. (example: I used "application" for mine)
  4. Ensure its weight is less than whatever action is using [node:node-path] so it executes first.
  5. Edit the action that uses [node:node-path], replacing that token with your newly created loaded content's version. (example: [application:node-path])

Tada. Basically, I think what Itangalo pointed out in comment #1 is pretty much what's happening. Making it load the node first ensures the alias is created before executing the rest of the actions.

dave reid’s picture

As far as the token goes, if [node:node-path] isn't returning the alias, then it simply means the alias hasn't been saved yet. We can't do more than try to return the result of drupal_get_path_alias('node/[nid]') which will return the same thing if there is no alias.

tr’s picture

Component: Rules Engine » Rules Core
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (outdated)