This would check how many of content type a user has currently authored.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mitchell’s picture

Component: Rules Core » Rules Engine
Category: feature » support

Since you would probably want to do this with an index instead of counting each time someone submits a node, one idea would be to use a per-content type, individual flag. Each time someone submits a node of that type, flag them. Then, perform another action once their flag_count reaches the threshold.

Flying Drupalist’s picture

Excellent suggestion, I'll definitely try this.

mitchell’s picture

Status: Active » Fixed

Marking as fixed.

Status: Fixed » Closed (fixed)

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

dremy’s picture

Component: Rules Engine » Rules Core

That is a great idea. Is there any way to set this up to validate for retroactive node posts. i.e. Set flag count = nodes of type posted?

mitchell’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev
Component: Rules Core » Documentation
Category: support » task
Status: Closed (fixed) » Active
Issue tags: +FAQ

Views Rules has a "Collect view result rows" action, and with a "List has count" condition on that generated variable, you should be able to easily apply this logic.

If you want to keep a valid, cached count of each view's results (to make a potentially long query very quick), you could setup Cache Actions or Cache Tags to run on each node creation and deletion.

dremy’s picture

@mitchell. This sounds like a great suggestion. I created a rule that has action "Collect view results rows", however I don't know where to find or add the "List has count" condition. It doesn't appear in the conditions above the actions on the rule page. Also is there any specific field to use just to have the "list has count" variable?

mitchell’s picture

@cooldom120: Hold on; I don't think that was right.

Attached is a very simple example that will rename all nodes to "hello, world". Import the view and the rule, then execute it on the components page.

Adding conditions like "author is", "node type is", "field contains", etc are some probable changes. These filters can actually be set within the view.

Are you going to run this as a one-time execution or a reaction? Please report back with some more background info so that either or both of us can write this up in the handbook afterwards.

mitchell’s picture

Hmm, this is about "user has #", so looping is not the goal. #1284266: Condition: "list has count" should be what is needed. I'll see if I can make a better fitting example.

dremy’s picture

@mitchell. Thank you for your response. This would be a reaction. Currently, it would work as such. When a user has added 5 articles (content type), then it would grant an achievement. I love the idea of using Views for this to check row count, or an aggregate total... Here is what I believe the rules config would look like. I'm struggling to find the correct way to enact Condition #2 (I tried Views Rules and it has been a bit hard to follow):

Event: Node is published

Condition #1:
Node type is "Articles"

Condition #2:
User has 5 Article Nodes published (currently attempting to pull their photos published count in through a view)

Action:
Grant achievement

erickva’s picture

Hi Mitchell, thanks for the suggestion. When I flag the user for content created, isn't the flag a On/Off boolean thing? How can I flag the user more than once if he creates 2 nodes of same content type? In my, fairly poor, understanding the count would always be one. Thank you.

Since you would probably want to do this with an index instead of counting each time someone submits a node, one idea would be to use a per-content type, individual flag. Each time someone submits a node of that type, flag them. Then, perform another action once their flag_count reaches the threshold.

TR’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

This seems to have been adequately addressed a long time ago.