How to find the right data selector in Rules Components? In Drupal 7, I have set up a rule to automatically close blog comments after two weeks. That works well.

Now, I am trying to have a block displayed on the blog entries when comments are closed. For this, I am using the Rules block visibility module.

I have set up the rule component as per the strict instructions of the module's "readme.txt" file. Without any condition, the export of the component gives this:

{ "rules_set_comments_closed_blocks_after_blog_entry" : {
    "LABEL" : "Display Comments Closed block on blog entries",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "module" : { "label" : "Module", "type" : "text" },
      "delta" : { "label" : "Delta", "type" : "text" },
      "result" : { "label" : "Result", "type" : "boolean", "parameter" : false }
    },
    "DO" : [ { "data_set" : { "data" : [ "result" ], "value" : "1" } } ],
    "PROVIDES VARIABLES" : [ "result" ]
  }
}


The problem I have is with the condition. I cannot find the right data selector in the Data Compare section.

If, on the other hand, I create a rule to display a system message on the site when comments are closed, I do find the data selector item "node:comment" and comparing its value to "NOT 2" (meaning not open) makes the message display only on blog entries with closed comments.

The above exported component works, but on all blog entries whether the comments are closed or not. I just need to add the condition to differentiate nodes with closed comments from those with open comments.

I have tried "entity" has field, entity is of type, etc. But, in components, the list of data selector is still very limited. In fact they are limited to site or current user items.

How can I expand the list of data selectors so that I find my "node:comment" (or similar) selector?

Any help on this is greatly appreciated. :)
Head over to the settings of your Rules Component, and specify "Node" as an extra parameter (on top of the 3 you already have in place). You can find "Node" within group "Entity".

After doing so, try again to add "Node" as your data selector, more specifically "Node:comment" (for which you want to test if its value is "0"). This time (after you added that extra parm) it should show up as a data selector.

Here is a sample Rules Component (in export format) that does something similar (it has an extra condition for "uid=1", which is probably not what you want).

{ "rules_block_visibility_hide_block_for_user_1" : {
    "LABEL" : "Hide block for user 1",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "module" : { "label" : "Module", "type" : "text" },
      "delta" : { "label" : "Delta", "type" : "text" },
      "result" : { "label" : "Result", "type" : "boolean", "parameter" : false },
      "node" : { "label" : "Node", "type" : "node" }
    },
    "IF" : [
      { "NOT data_is" : { "data" : [ "site:current-user:uid" ], "value" : "1" } },
      { "data_is" : { "data" : [ "node:comment" ], "value" : "0" } }
    ],
    "DO" : [ { "data_set" : { "data" : [ "result" ], "value" : "1" } } ],
    "PROVIDES VARIABLES" : [ "result" ]
  }
}


If you just import the above Rules Component, it already has that "Node" as an extra parameter.

Note: if you get unexpected errors (after enhancing your Rules Component as suggested above), then enable Rules debugging (so see the Rules debugging log). You can do this via /admin/config/workflow/rules/settings