Author Topic: Total views for lightboxes  (Read 5169 times)

0 Members and 1 Guest are viewing this topic.

Offline MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Total views for lightboxes
« on: May 14, 2012, 02:37:48 PM »
Hello!

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_lightboxesADD `lightbox_hitsINT(10UNSIGNED 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);
  
    
$sql "UPDATE ".LIGHTBOXES_TABLE." l
          SET l.lightbox_hits = l.lightbox_hits + 1
          WHERE l.lightbox_id = '"
.$lightbox_id."'";
  
$site_db->query($sql);
     
}


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

4. Find:
$site_template->register_vars(array(
Paste:
"lightbox_hits" => $row['lightbox_hits'],

5. In the lightbox.html use {lightbox_hits}

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

Regards,
Andrew
« Last Edit: May 15, 2012, 10:22:52 AM by MrAndrew »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: How to fix, hits in lightbox?
« Reply #1 on: May 15, 2012, 04:02:38 AM »
Where exactly did you put this code?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)