Hello,
I have integrated fancybox3 in my theme (yes it works fine!) and I wish now to use the fancybox javascript event (afterShow) to increment the hitcounter of the displayed image in Zenphoto database.
The idea is to create a js function, that send a http request to a php script that would add 1 to hitcounter. This mechanism used to run fine with Menalto gallery2.
Js function in album.php
<pre>[code]
function counter(itemId) {
alert(itemId);
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
}
xmlhttp.open("GET","/counter.php?id="+itemId,true);
xmlhttp.send();
}
[/code]</pre>
I have found in extension slideshow2 slideshow-counter.php that could be the base for counter.php I would need to adjust to increment the hitcounter.
<pre>[code]
require_once("../../functions.php");
$album_name = sanitize($_GET["album"]);
$img_name = sanitize($_GET["img"]);
if ($album_name && $img_name ) {
$album = newAlbum($album_name);
$image = newImage($album, $img_name);
//update hit counter
if (!$album->isMyItem(LIST_RIGHTS)) {
$hc = $image->getHitcounter()+1;
$image->set('hitcounter', $hc);
$image->save();
}
}
[/code]</pre>
Any idea if that could work ? Any other simpler solution between JS and PHP/ZP?
Thanks for your feedback...