I've a rule to show user a message when he first visit a page.
I have 3 conditions:
- User has role;
- Data comparison on a profile field;
- Path has URL alias;

No message is shown when I visit the page with the corresponding alias (I've tried with both system URL or path).
Removing the path alias condition makes the rule running fine.
What can be wrong?
I don't have clean url's enabled: could it be a problem?

Comments

mitchell’s picture

Version: 7.x-2.0-beta1 » 7.x-2.0
Status: Active » Fixed

>> I don't have clean url's enabled: could it be a problem?
No.

>> Removing the path alias condition makes the rule running fine.
I think you're supposed to fill in a value here, otherwise it will fail every time.

Status: Fixed » Closed (fixed)

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

pmichelazzo’s picture

I have the same issue here. Trying different methods and no one give a result.

Someone have a clue about it?

Thanks

mitchell’s picture

Category: bug » support
Status: Closed (fixed) » Postponed (maintainer needs more info)

(maintainer note: This obviously isn't very straight forward...)
First off, there isn't a condition in 7.x for "path has alias." You need to use a data comparison with [site:current-page:path] and contains. I think this contains part is the weakest link in usability. There are probably improvements to be made there. Anyway, here's something to try out:

{ "rules_test_path_reaction" : {
    "LABEL" : "test path reaction",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "node_view" ],
    "IF" : [
      { "OR" : [
          { "data_is" : {
              "data" : [ "site:current-page:path" ],
              "op" : "contains",
              "value" : "node\/"
            }
          },
          { "data_is" : {
              "data" : [ "site:current-page:path" ],
              "op" : "contains",
              "value" : "content\/"
            }
          }
        ]
      }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "You are viewing a node called [node:title]." } }
    ]
  }
}
videographics’s picture

I can paste this is and get a rule with a comparison action utilizing the 'contains' operator, but when creating new data comparison actions, "contains" is not an option.

mitchell’s picture

Version: 7.x-2.0 » 7.x-2.1
Component: Rules Engine » Rules Core
Status: Postponed (maintainer needs more info) » Active
Issue tags: +Needs documentation, +FAQ

...clarity is a WIP :p

That method was deprecated as of, #1319470: check for multiple selected options. Here's the actual diff:
http://drupalcode.org/project/rules.git/commitdiff/51826e3326df64bfa7eaf...

This was a bit difficult to track down, because the condition names are a bit wonky. "Is" and "Matches" are used in the code interchangeably with "Comparison."

Either way, Text comparison functionally makes more sense for this case than Data comparison, but that will have to be cleared up with improved help text.

If you are still looking for more info on how to set this up, see #1045964: How to do path detection, until there is an actual canonical description in the handbook. Soon........................

videographics’s picture

Thanks for the clear run down on what's happening with this. Progress....

ntigh52’s picture

Ho to all,
There is a condition in 7.x for "path has alias." that dont work if i add a condition path = node/3 (for example), Why I need to use a data comparison with [site:current-page:path] and contains.
mitchell helped me a lot to solve the issue with the trick (use data comparison with [site:current-page:path] and contains),
but is ta not a bug ?
THanks/

TR’s picture

Issue summary: View changes
Status: Active » Fixed

This seems to have been answered. Note, "node/3" is not an alias - it is a path. "Path has alias" only works for path alias, that is, an *alternative* path that has been explicitly set for the node. If you edit your node and scroll down to the bottom and click on the "URL path settings" vertical tab, if there is no alias entered in that field then "Path has alias" will return false.

TR’s picture

Status: Fixed » Closed (fixed)