I added a
field_limit to Taxonomy, so that I can add term within "limit" number. Here is a steps that I did:
Question: How to limit the number of nodes to be equal or less the
Use the Views and Views Bulk Operations module to create a view of all nodes that have a specific taxonomy term, in which you add a VBO field to it. Simply include a field like
nid for each node (no need for any other fields). Just make sure you get exactly 1 row for each node you want to take into consideration.
Create a Rules Component like so:
Using these Rules Component parameters:
node_termreference (which can be either a single value, or it can have multiple values, depending on how you defined it in your content type).
With a Rules Condition "Check number of results returned by a VBO view", whereas:
node_limit (which is the 1st parameter used by this Rules Component).
node_termreference field (which is the 2nd parameter used by this Rules Component); Which Rules Action to use for doing so depends on how that field is defined, e.g if it is a multi value field, then you should use "remove from list".
Create a custom Rule like so:
node_termreference parameter to execute the Rules Component from Step 2 later on.
node_limit parameter to execute the Rules Component from Step 2 later on.
node_termreference to actually perform its logic.
PS: the above is only a blueprint ... Mostly because your question has not sufficient details. E.g you didn't explain how those terms are defined in your content type).
I think if you work with node using Node Form, you should use hook_node_validate
I do not think any contributed module having this feature yet. You need to do little bit customization for this.
You put some condition in hook_node_validate to check how much node associated with that node and compare with the limit you have set.
You can use function taxonomy_select_nodes to Return nodes attached to a term across all field instances.
Limitation :::This function requires taxonomy module to be maintaining its own tables, and will return an empty array if it is not. If using other field storage methods alternatives methods for listing terms will need to be used.