Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $tv = $modx->getObject('modTemplateVar', array('name' => 'hitcount'));
- $criteria = array(
- 'tmplvarid' => $tv->get('id'),
- 'contentid' => $modx->resourceIdentifier
- );
- if(!$tvResource = $modx->getObject('modTemplateVarResource', $criteria)){
- $tvResource = $modx->newObject('modTemplateVarResource');
- $tvResource->set('value', 1);
- $tvResource->set('tmplvarid', $tv->get('id'));
- $tvResource->set('contentid', $modx->resourceIdentifier);
- $tvResource->save();
- } else {
- $value = (int)$tvResource->get('value') + 1;
- $tvResource->set('value', $value);
- $tvResource->save();
- }
Add Comment
Please, Sign In to add comment