You are here

README.txt in Nodereference Count 6

Same filename and directory in other branches
  1. 7 README.txt
Nodereference Count
-------------------
This is a CCK field type that will count the number of nodereferences to a 
particular node.  The count is updated both when the node that is being counted 
is saved, as well as when a node that is referencing the node being counted is 
saved, updated or deleted.  It will count references from individual 
nodereference fields as well as aggregate counts from multiple nodereference 
fields to the same node.

This should be an improvement over alternate solutions to the same problem, 
such as: 
Using a computed field, which would either be updated when viewed, but not 
available to views, or when saved, but not when a nodereference was added or 
removed.  Or a view, which would be updated when displayed, but with a 
performance price and not be available within the node itself.

Formatters
----------
Two display formatters are provided.  The default formatter will display all 
counts including zero.  The 'non-zero' formatter will hide the count if it is 
zero, but display the count for anything greater.

Installation
------------
Copy nodereference_count to your module directory and then enable on the admin
modules page.  Be sure you have at least one nodereference field configured and 
then add a nodereference count field to a content type that is referenced by a 
nodereference.  Check the boxes for the nodereference fields that should be 
counted.  You will need to re-save any existing nodes or their referencing nodes 
in order to update the count.

Updating counts for pre-existing nodereferences
-----------------------------------------------
While the nodereference count fields will be updated when the node is saved or 
when the referencing node is saved, that isn't much help for pre-existing 
nodereferences to nodes created prior to the addition of a nodereference count 
field.  The Views Bulk Operations (VBO) module, 
http://drupal.org/project/views_bulk_operations, is the recommended solution .  
Using VBO you can re-save all of the nodes that have a nodereference_count 
field.  
That will update the count for each of those nodes.  The specifics will vary for 
each site, but the general instructions for doing this with VBO are as follows:

  - Install the Views and VBO modules if you do not already have them installed.
  - Go to /admin/build/views/add and create a new node view.
  - Create a new page display.
  - Change the style from Unformatted to Bulk Operations.
  - Select 'Use Batch API' under TO EXECUTE OPERATIONS.
  - Check 'Save post (node_save_action)' under SELECTED OPERATIONS.
  - Click 'Update default display'.
  - Add a path under Page Settings.
  - Add 'Node: Title' under Fields.
  - Add 'Node: Type' under Filters.  Be sure to select the node types that 
  contain nodereference_count fields.
  - Save the view.
  - Visit the path that you set for the view.
  - Select all the nodes.
  - Click 'Save post'.  
  - Your nodereference_count fields should now be updated.
  - You are unlikely to need to use the view again, so feel free to delete it if 
  you like.

Author
------
Brendan Andersen
brendan@omnifik.com

File

README.txt
View source
  1. Nodereference Count
  2. -------------------
  3. This is a CCK field type that will count the number of nodereferences to a
  4. particular node. The count is updated both when the node that is being counted
  5. is saved, as well as when a node that is referencing the node being counted is
  6. saved, updated or deleted. It will count references from individual
  7. nodereference fields as well as aggregate counts from multiple nodereference
  8. fields to the same node.
  9. This should be an improvement over alternate solutions to the same problem,
  10. such as:
  11. Using a computed field, which would either be updated when viewed, but not
  12. available to views, or when saved, but not when a nodereference was added or
  13. removed. Or a view, which would be updated when displayed, but with a
  14. performance price and not be available within the node itself.
  15. Formatters
  16. ----------
  17. Two display formatters are provided. The default formatter will display all
  18. counts including zero. The 'non-zero' formatter will hide the count if it is
  19. zero, but display the count for anything greater.
  20. Installation
  21. ------------
  22. Copy nodereference_count to your module directory and then enable on the admin
  23. modules page. Be sure you have at least one nodereference field configured and
  24. then add a nodereference count field to a content type that is referenced by a
  25. nodereference. Check the boxes for the nodereference fields that should be
  26. counted. You will need to re-save any existing nodes or their referencing nodes
  27. in order to update the count.
  28. Updating counts for pre-existing nodereferences
  29. -----------------------------------------------
  30. While the nodereference count fields will be updated when the node is saved or
  31. when the referencing node is saved, that isn't much help for pre-existing
  32. nodereferences to nodes created prior to the addition of a nodereference count
  33. field. The Views Bulk Operations (VBO) module,
  34. http://drupal.org/project/views_bulk_operations, is the recommended solution .
  35. Using VBO you can re-save all of the nodes that have a nodereference_count
  36. field.
  37. That will update the count for each of those nodes. The specifics will vary for
  38. each site, but the general instructions for doing this with VBO are as follows:
  39. - Install the Views and VBO modules if you do not already have them installed.
  40. - Go to /admin/build/views/add and create a new node view.
  41. - Create a new page display.
  42. - Change the style from Unformatted to Bulk Operations.
  43. - Select 'Use Batch API' under TO EXECUTE OPERATIONS.
  44. - Check 'Save post (node_save_action)' under SELECTED OPERATIONS.
  45. - Click 'Update default display'.
  46. - Add a path under Page Settings.
  47. - Add 'Node: Title' under Fields.
  48. - Add 'Node: Type' under Filters. Be sure to select the node types that
  49. contain nodereference_count fields.
  50. - Save the view.
  51. - Visit the path that you set for the view.
  52. - Select all the nodes.
  53. - Click 'Save post'.
  54. - Your nodereference_count fields should now be updated.
  55. - You are unlikely to need to use the view again, so feel free to delete it if
  56. you like.
  57. Author
  58. ------
  59. Brendan Andersen
  60. brendan@omnifik.com