Support CCK node references by copying all voting data from the reviewed node into the referenced node upon node load.

Themers may then pick up the voting data from either node.

Comments

dfletcher’s picture

After quite a bit of discussion in IRC with eaton, quicksketch, and morphir, I believe we have a bit more work to do than simply copying the data to the referenced node.

The best example so far comes from quicksketch who has shown me a decent example of a comment based reviewing system.

From these discussions, I believe this can be supported in two ways:

  1. When a nodereference field exists on a review node, a vote is placed for both nodes. Therefore, one node represents an individual vote, the other an aggregate one. This also works for the simpler case where a node ref is created just for a separation of a review from the main content (which was the case I was imagining originally).
  2. We will supply a hook for PHP programmers (subject to change):
    function hook_votingapi_field_reference($node);
    

    Modules can implement this hook and return an array of other node IDs which must receive a copy of the vote. This hook might be implemented in votingapi_field itself in order to provide the functionality for nodereference.

dfletcher’s picture

Perhaps in addition to the noderef support above, we can also implement quicksketch's original idea of having a PHP input box for attaching node refs. Let's hide it under an "advanced" tab though.

morphir’s picture

I am not sure if the user who post the review/rating should figure out what node he are referring to. This should be automatically in some way.

I foresee when you surf your way to the parent node, you can rate that parent node in a review-article way.
Where your review/article automatically becomes the child node to the parent node that holds the average data/sum and what not.. This is something I foresee could be dealt with trough views module.

When it comes to choosing your parent node(from a user point of view) there will be a lot of categories and terms for the user to choose between. And I think that it becomes to difficult for the user to deal with so much decisions.

Category_browse is also needed module(that have not yet been made) which could be very handy for this purpose.

dfletcher’s picture

What I've described here is effectively the same as your parent/child idea except these things aren't exactly called "parent" and "child". The best names I've come up with so far is "referencing node" and "referenced node".

The nodereference support is just a simpler way for non-PHP users to have a way to pick this relationship at node creation time with a nice user interface.

Both the GUI (nodereference) and the non-GUI (PHP code) ways of doing this will both support a many-to-one relationship between one node and a set of relations. The idea behind the hook (and the PHP input box) is that you can use some code to attach a review to some other node, saving the author from having to do it each time. For example, if node based comments are attached to a "parent" node, some PHP code could specify that the comment is the users's single vote and the results must be aggregated on the "parent".

dfletcher’s picture

One final feature that would make this whole thing much more useful is to have user and author versions of all 3 types of widgets. Currently there is only one author field called "Author Rating" which is very similar to the "User Score" but is controllable by node author. This should be repeated for the other two types, for a total of six possible widgets:

  • User Choice
  • Author Choice
  • User Score
  • Author Score
  • User Percent
  • Author Percent

While I'm rearranging these perhaps I can make the "add field" page prettier by putting all the items in one group.

dfletcher’s picture

There is a basic working version of this in CVS now. Nodereference is working, PHP hooks are working. There is no PHP input box yet.

There is no display of these referenced votes yet. Perhaps the solution is to define display-only voting fields that can be applied to the referenced node type (if it is CCK). These would display the aggregated value. Another possibility is to lookup and attach this data at node load time.

dfletcher’s picture

The data is now available on $node objects during theming. It is added on hook_nodeapi, $op=='load'. There is no currently no way to display the data without a bit of code in a theme though. This needs improvement (obviously).

morphir’s picture

Perhaps the solution is to define display-only voting fields that can be applied to the referenced node type (if it is CCK). These would display the aggregated value. Another possibility is to lookup and attach this data at node load time.

I agree. This is the solution.