Hi, first off wanted to say fantastic work on zenPhoto and congrats on the 1.0 release. I was using gallery2 and was fed up with the bloat as I don't want other users, just me, and I wanted something looking smart and simple. I found zenPhoto and realised the description is just what I was wanting to type into google!! haha.
I have moved my personal gallery over from G2 to zenPhoto (~300 pics).
My request if for some kind of view counts (per image), it may not be wanted for all but if the data was available in the db then it could be used on the templates.
Also, when will we see EXIF data available?
Again, great work, thanks!
Comments
However I have implemented a basic view count in the image context. (Once I'd found classes.php this was a doddle!) And yes I will be aware that my changes will be overwritten with any upgrades, after all its in beta still, so I won't be moaning that I lost anything! )
http://austinandteresa.co.uk if you wanna see
When I get this and later on inner albums, ZenPhoto is starting to have everything I need.
Inside /themes/<your current theme>/index.php
find the div
`
then after the line
`
<?php printAlbumDesc(); ?>
`I have put (to get only number of images in this album):
`
<? $number = getNumImages(); if ($number != 1) $number .= " photos"; else $number .=" photo"; echo$number; ?>
Then for the album pages to get xx to xx of xx:
Inside /themes/<your current theme>/album.php
after the line
`<?php printAlbumDesc(true); ?>`
I have put:
`
<? echo((($_zp_page - 1) * zp_conf('images_per_page')) + 1); ?> to <? $pgtotal = ($_zp_page * zp_conf('images_per_page')); $numimg = getNumImages(); if ($pgtotal > $numimg) echo$numimg; else echo$pgtotal; ?> of <? $number = getNumImages(); if ($number > 1) $number .= " photos"; else $number .=" photo"; echo$number; ?>
This calculation looks awful and is probably not very elegant but gets there! I don't think I needed to add any extra functions for that but it was a few weeks ago now.
To get view counts then you need to add a new field in the images table and new class functions to to read and increment this value
Normal disclaimer of use code at own risk etc etc...
insert into image.php
'<?
$id = getImageID();
query("UPDATE z_images SET hit = hit + 1 WHERE id=$id");
$views = query_full_array("SELECT hit FROM z_images WHERE id = $id" );
foreach ($views as $view) {
$numviews = $view['hit'];
echo "$numviews";
}
?>'
MySQL Query ( UPDATE z_images SET hit = hit + 1 WHERE id=2395 ) Failed. Error: Table 'db0006382.z_images' doesn't exist
my mysql prefix is zen_ - using the prefix instead of z_images fails either.
What can I do?
Maybe somebody implemented another view counter?
And, i forgot to mention, that you have to make a new field in this DB, called HIT. In mysql it looks like this hit int(11) NOT NULL default '0'. I hope you'll do it, it is not that hard. It means name = hit, type = INT(11), NUL=no, default=0.
Ok - I changed the prefix.
Can you tell me how to make the field in the DB? It´s not my own server - it´s run by a webhost.
Or you can make an SQL query, the code is as follows: ALTER TABLE `z_images` ADD `hit` INT( 11 ) NOT NULL ;
Especially your scrennshots helped a lot. let me see how to beautifully integrate the counter ...
here is my total story from begin till end, it might help people!
Here it comes, but before that, you'll need a new row in table images of your gallery. Make a row that looks like: hit int(11) NOT NULL default '0'.
Now the counting can be saved in our database, we can post the code to count the views:
in image.php of your gallery:
'<?
$id = getImageID();
query("UPDATE z_images SET hit = hit + 1 WHERE id=$id");
$views = query_full_array("SELECT hit FROM z_images WHERE id = $id" );
foreach ($views as $view) {
$numviews = $view['hit'];
}
?>'
Now the counts are saved, we can custom made zenpressed:
Add the function:
/* shows most viewed photos */
function zenpressed_mostviewedphotos( $album = null, $conf = null ) {
$conf = zenpressed_conf( $conf );
$conf["select"] = "mostviewed";
return zenpressed_photos( $album, $conf );
}
Add the select:
elseif( $conf["select"] == "mostviewed" ) $query_order = " ORDER BY images.hit DESC";
Add the function call in your sidebar.php:
<h4>Meest bekeken foto's</h4>
<?php $wpdb->select(DB_NAME); // reconnect wordpress db ?><?php zenpressed_mostviewedphotos( ); ?>
And we are done! Pretty cool heh!
If you need an example, you can watch it at www.royz.nl!
<?
if (zp_loggedin()) {
$id = getImageID();
$views = query_full_array("SELECT hit FROM clientz_images WHERE id = $id" );
foreach ($views as $view) {
$numviews = $view['hit'];
}
} else {
$id = getImageID();
query("UPDATE clientz_images SET hit = hit + 1 WHERE id=$id");
$views = query_full_array("SELECT hit FROM clientz_images WHERE id = $id" );
foreach ($views as $view) {
$numviews = $view['hit'];
}
}
?>
Then to display your page views (depending on your theme) place
echo "$numviews";
where you want the count to show. For Cimi (my current favorite theme) I used:
<div class="block light"><? echo "$numviews"; ?> views</div>
This went somewhere below the LEFT and RIGHT arrow buttons.
What can I say. It works. Three cheers for Tristan and his band.