Sounds easy, but I couldn't set up a rule wich would compare number of node's comment to a value of field, let's call it 'goal'.
What I did was:
1. On 'admin/config/workflow/rules/reaction/add' I have created new rule called 'Make Sticky' and selected 'After saving a new comment' for 'React on event'.
2. On 'admin/config/workflow/rules/reaction/manage/rules_make_sticky' I clicked 'Add condition' and selected 'Data Comparison'.
3. On a newly opened page I selected 'comment:node:comment-count' for Data Selector and clicked Continue.
4. On the next page I selected 'is greater that' and arrived to the dead-end.
Because, for 'Value' I need value of a custom field_goal and there is no such option among data selectors. Maybe the value of field_goal can be pulled out by PHP code in PHP evaluation section provided on the same page, but maybe Rules simply don't allow comparing with content fields at all.
Anyway, I need someone more experienced to help me in setting up the necessary rule or, if the last is the case then, to write a small module which triggers only on comment add and which makes a node sticky if the number of comments is greater than a value set in field_goal. I have $30 for this little piece.
Anyone?
Comments
So I currently have the
So I currently have the folling exported code for the rule:
I wonder is there any way to make Rules compare data with field values, something like:
Add a condition of 'Entity
Add a condition of 'Entity has Field' first and assert that the node has the field field_goal. From there you should have access to it in your data selectors (you'll have to make sure the field assertion comes before the comparison).
Thanks for the input. I have
Thanks for the input. I have added field assertion, but unfortunately the field is still not available in data selectors.
What type of field is
What type of field is field_goal?
This works for me:
Bounty is taken by a custom
Bounty is taken by a custom module developer, I've got my issue solved. Nevertheless would be nice if this could also be reached by Rules module.
Hi, Here's the small module
Hi,
Here's the small module for this, make a folder called makesticky under sites/all/modules/ and put this two files inside the makesticky folder :
makesticky.module :
makesticky.info :
Enable the module and check if it works for you.
Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form
Sagar, Thanks for the input,
Sagar,
Thanks for the input, but I'd like to cite from my last post above:
. Sorry but I had already got the issue solved.
That's fine, thank you for
That's fine, thank you for the bounty anyways.
Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form
for your doxygen, Sagar :
for your doxygen, Sagar : implements hook_comment_save, shouldn't that be hook_comment_insert?
Hi, My bad, comment was wrong
Hi,
My bad, comment was wrong but used hook_comment_insert in the code.
Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form