I think, I would go a step further, and create a custom-table for the faqs.
Then its easy to set the yes/no - click-counts at the faq - record.
Ok, I have created my custom table like you had suggested. The 'yes' and 'no' are of type integer. How would I increment those fields' values from the front end of the website?
do you have created a xpdo-schema for the table?
If so, could you post it here?
I think, something like that should work:
<?php
$packageName = 'faqs';
$packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
$modelpath = $packagepath . 'model/';
$prefix = null;
if (is_dir($modelpath)) {
$modx->addPackage($packageName, $modelpath, $prefix);
}
$classname = 'faqs';
$object_id = (int) $modx->getOption('object_id',$_GET,0);
$add_yes = (int) $modx->getOption('add_yes',$_GET,0);
$add_no = (int) $modx->getOption('add_no',$_GET,0);
$field = !empty($add_yes) ? 'yes' : '';
$field = !empty($add_no) ? 'no' : $field;
if (!empty($field) && !empty($object_id) && $object = $modx->getObject($classname,$object_id)){
$count = $object->get($field) + 1;
$object->set($field,$count);
$object->save();
}
return '';
with buttons like
<a href="[[~[[*id]]? &object_id=`[[+id]]` &add_yes=`1`]]">Yes</a>
<a href="[[~[[*id]]? &object_id=`[[+id]]` &add_no=`1`]]">No</a>
you might also want to set a cookie or SESSION - var and check, if the user allready has clicked the button.
everything untested!
[ed. note: Bruno17 last edited this post 10 years, 11 months ago.]