4images Forum & Community

General / Allgemeines => Programming => Topic started by: MrAndrew on May 14, 2012, 02:37:48 PM

Title: Total views for lightboxes
Post by: MrAndrew on May 14, 2012, 02:37:48 PM

This little modification i`ve created for my gallery. I think it might be useful to someone else!

Q: What is that modification do?
A: This mod, will count the number of hits for each album and record the value in the database every time someone would see the photo album. Just 4 steps for modification. P.S. This work in all versions of 4images, and not depends on each installed MODs..

1. Create a table in 4images_lightboxes

ALTER TABLE `4images_lightboxes` ADD `lightbox_hits` INT(10) UNSIGNED AS DEFINED 0;

2. In lightbox.php find

//--- Show Images -------------------------------------
if ($action == "show")

Add after:

//Update lightbox Hits
if ($user_info['user_level'] != ADMIN) {
  $lightbox_id = (isset($HTTP_POST_VARS['lightbox_id']) && $HTTP_POST_VARS['lightbox_id']) ? $HTTP_POST_VARS['lightbox_id'] : ((isset($HTTP_GET_VARS['lightbox_id']) && $HTTP_GET_VARS['lightbox_id']) ? $HTTP_GET_VARS['lightbox_id'] : 0);
          SET l.lightbox_hits = l.lightbox_hits + 1
          WHERE l.lightbox_id = '".$lightbox_id."'";

3: Directly under 2 step, find sql query and at the end of line paste: , l.lightbox_hits

4. Find:
"lightbox_hits" => $row['lightbox_hits'],

5. In the lightbox.html use {lightbox_hits}

This is end! Take a look! Enjoy ;-)

Title: Re: How to fix, hits in lightbox?
Post by: V@no on May 15, 2012, 04:02:38 AM
Where exactly did you put this code?