artdevue / LikeDislike

LikeDislike flexible extension of voting for MODX Revolution. It allows visitors to vote for anything you want on your website.
http://like.artdevue.com
10 stars 8 forks source link

Store rating in more than one TV #7

Open artelse opened 11 years ago

artelse commented 11 years ago

I would to be able to store plus and minus votes in different TV's in my resource. This enables me to rank resources based on these parameters. It would be great to send an array of output options. If it's an easy hack, would love to get a pointer on how to do that.

artdevue commented 11 years ago

Hello! To solve this issue create two TVs with names: _votes_up_(example id = 5) & _votes_down_(example id = 6), then in plugin likeDislikePlugin change code lines  (23-26)

$tvs = $modx->getObject('modTemplateVarResource',array('tmplvarid'=>$idtv, 'contentid'=>$idRes));
                    if($tvs) {
                        $tvs->set('value',$setObj);
                        $tvs->save();

on these lines

$tvUp = $modx->getObject('modTemplateVarResource',array('tmplvarid'=>5, 'contentid'=>$idRes));
$tvDown = $modx->getObject('modTemplateVarResource',array('tmplvarid'=>6, 'contentid'=>$idRes));
                    if($tvUp && $tvDown) {
                        $tvUp->set('value',$params['votes_up']);
                        $tvDown->set('value',$params['votes_down']);
                        $tvUp->save();
                        $tvDown->save();

Now make you snippet call LikeDislike with parameters:

&rating=`type=1,tv=votes_up`

Don't forget to clear chache and assign your TV to resource templates.

and use with 'tmplvarid' your TV ID - for example: 'tmplvarid'=>5

artelse commented 11 years ago

Thanks for the response. I can't get it to work because the $tvUp and $tvDown are not initiated somehow. I do have the TVs assigned to my resource and referenced the right id #. Any idea?

artdevue commented 11 years ago

Hi  In the next version I will include tvUp and tvDown in the settings.Plug in for the event OnlikeDislikeSave can transfer any data for the vote.You can write on the level of IP MODX. Thank you Best regards, Valentin

artelse commented 11 years ago

Great, that makes sense as it enables to tie in ldl data much closer to one's own data set (resources with tv's). ETA? Thanks!