This is my initial attempt at a rate field. Not sure if I did it all correctly, I used email.module as a guide.
Tested only on a custom options widget. I decided to do this as a module and if it all works ok it could be merged into the rate.module code itself.
I have a added a rate widget selection, and a php textarea that picks the target to be rated.

Many things may be missing / not working , so please update where you can!

CommentFileSizeAuthor
ratefield.tar_.gz1.44 KBchrisroditis

Comments

Luna Vulpo’s picture

I try your module but I get this errors, when I adding a new field.

    Notice: Undefined index: rate_widget in ratefield_field_widget_settings_form() (line 77 of /.../sites/all/modules/ratefield/ratefield.module).
    Notice: Undefined index: rate_widget in ratefield_field_widget_form() (line 112 of /.../sites/all/modules/ratefield/ratefield.module).
    Notice: Undefined index: rate_widget in ratefield_field_widget_form() (line 114 of /.../sites/all/modules/ratefield/ratefield.module).
    Notice: Trying to get property of non-object in rate_embed() (line 624 of /..../sites/all/modules/rate/rate.module).
andypost’s picture

Great idea, but for 1.x branch you need just implement hook_field_extra_fields()

IWasBornToWin’s picture

Is this working in new dev? Can we use it as a field yet?

mauritsl’s picture

Not yet, I've implemented this yesterday evening. 2.x branch is outdated, I will update it soon.

IWasBornToWin’s picture

Excellent, thanks

IWasBornToWin’s picture

Sorry to bother you but how long do you think it will be before this can be added as a field, or used on different node/comment types?

mauritsl’s picture

I plan to release a beta somewhere begin april (but no guarantees on vulunteer work..)

Please note that you can already activate the widget on different node/content types in the 1.x branch. See the edit widget page in the admin.

IWasBornToWin’s picture

Thank you. My big challenge is being able to use it on comments and only show the tally of votes on the node. I am looking for a solution which will allow a user to vote as many times as they want on comments and the node simply shows the totaled average.

mauritsl’s picture

I'm exploring new ways for vote aggregation, but that will not make it in the first 2.x release either.

For now you have to go with some custom code. This can be done by implementing hook_votingapi_insert():

function MODULE_votingapi_insert($votes) {
  foreach ($votes as $vote) {
    if ($vote['content_type'] == 'comment') {
      // Get node id by comment id (available in $vote['content_id']
      // Save vote to node via votingapi_set_votes()
    }
  }
}
IWasBornToWin’s picture

I'm grateful for your responses. I have no idea where to put that code. I do my best not to hack core if I can help it. I also use Views Css code module. Is there a way I can put this code in a veiws php module or what? Just to know, I use Views to view the nodes and comments I want to use rates for. So, I assume your code is saying--if I get votes on a bunch of comments to total those votes for the comment node?

What field would I use to put the votes in(or would I create a field) since Rate doesn't allow me to use comments? Sorry for all the questions.

Thank you again.

ocamp’s picture

Would this way work with fields instead of comments?
like
$vote['node'][ 'title']
$vote['node'][ 'body']

Anything like that?

Thanks

spgd01’s picture

Any progress on this? It will greatly help with display.

AncientSwordRage’s picture

Issue summary: View changes

Any progress on this yet?

ivnish’s picture

Assigned: chrisroditis » Unassigned
Status: Needs review » Closed (outdated)

Drupal 7 is EOL. Issue will be closed, but patches are still here

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.