Advertisement
krot

MODX plagin setrank

Sep 22nd, 2017
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. rankset плагин
  2. /*
  3. <?php
  4. $res = $modx->getObject('modResource', $modx->resourceIdentifier);
  5. $rank = $res->getTVValue('rank');
  6. $res->setTVValue('rank',$rank+1);
  7. */
  8. Event: OnLoadWebDocument:
  9. <?php
  10. $rank =$modx->resource->getTVValue('rank');
  11. $modx->resource->setTVValue('rank',$rank+1);
  12.  
  13. snippet:
  14. <?php
  15. /*$tvs = $modx->getCollection('modTemplateVar', array('name' => 'rank'));
  16. $tvid=array_keys($tvs);
  17. $tvid=$tvid[0];
  18.  
  19. $tvs = $modx->getCollection('modTemplateVarResource', array('tmplvarid' => $tvid));
  20. $sumrank=0;
  21. foreach ($tvs as $k => $tv) {
  22.     $t= $tv->toArray();
  23.     $sumrank+=$t['value'];
  24. }
  25. print "<pre>";
  26. print_r($sumrank);*/
  27.  
  28.  
  29. $user = $modx->user;
  30. $resources = $user->getMany('CreatedResources');
  31. foreach ($resources as $res) {
  32.     $views = $views + $res->getTVValue('rank');
  33. }
  34. echo $views;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement