austega
Member
Hi Hugh,
Back with an additional question following on from #40725 - hopefully solvable without any TV session!
I have listed below your PHP and JS code for our PHP List plugin, together with some proposed adds/edits intending to increment a resource's hits value stored in the erd_resources table each time a user clicks on the PHP List icon. As you know my expertise in PHP/Joomla DB is limited - could you please eye-check and advise?
The ## at the start of lines indicate changes from your code.
Also if I wished to open up the resources in a new browser window/tab rather than the existing one, can I just replace " window.location.href = path; " with " window.open(path); "?
PHP Code
--------
// ADD the following to update Hits
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "UPDATE #__erd_resources SET hits = hits + 1 WHERE id=".$row->($id) ;
$db->setQuery($query);
$result = $db->execute();
// END ADD
$app = JFactory::getApplication();
$ids = $app->input->get('ids', array(), 'array');
$id = array_pop($ids);
$ids_str = json_encode($ids);
$row = $model->getRow($id);
$path = $row->erd_resources___link;
## $linktype = $row->erd_resources___linkTypeId;
## if (!empty($path) and $linktype=2)
{
system($path);
exit;
}
$statusMsg = "Ids: " . $ids_str . "," . $id . " Path: " . $path;
JS Code
-------
// rows is an array of objects representing the selected table rows.
// You might need to add the _raw prefix to the full element name, depending on the field type (e.g. if its a dropdown).
var linkTypeId = parseInt(rows[0].erd_resources___id_linktype, 10);
var path = rows[0].erd_resources___link;
if (linkTypeId != 2) {
window.location.href = path;
## REMOVE return false;
}
Back with an additional question following on from #40725 - hopefully solvable without any TV session!
I have listed below your PHP and JS code for our PHP List plugin, together with some proposed adds/edits intending to increment a resource's hits value stored in the erd_resources table each time a user clicks on the PHP List icon. As you know my expertise in PHP/Joomla DB is limited - could you please eye-check and advise?
The ## at the start of lines indicate changes from your code.
Also if I wished to open up the resources in a new browser window/tab rather than the existing one, can I just replace " window.location.href = path; " with " window.open(path); "?
PHP Code
--------
// ADD the following to update Hits
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "UPDATE #__erd_resources SET hits = hits + 1 WHERE id=".$row->($id) ;
$db->setQuery($query);
$result = $db->execute();
// END ADD
$app = JFactory::getApplication();
$ids = $app->input->get('ids', array(), 'array');
$id = array_pop($ids);
$ids_str = json_encode($ids);
$row = $model->getRow($id);
$path = $row->erd_resources___link;
## $linktype = $row->erd_resources___linkTypeId;
## if (!empty($path) and $linktype=2)
{
system($path);
exit;
}
$statusMsg = "Ids: " . $ids_str . "," . $id . " Path: " . $path;
JS Code
-------
// rows is an array of objects representing the selected table rows.
// You might need to add the _raw prefix to the full element name, depending on the field type (e.g. if its a dropdown).
var linkTypeId = parseInt(rows[0].erd_resources___id_linktype, 10);
var path = rows[0].erd_resources___link;
if (linkTypeId != 2) {
window.location.href = path;
## REMOVE return false;
}