Author Topic: [Feature-addon] - Total count for lightbox (how many images you added).  (Read 53069 times)

0 Members and 1 Guest are viewing this topic.

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
// Introduction

This feature was already published by V@no in the past but seems to have been lost on the old forum. However, since the code was never found again, I have decided to re-code it myself. ;)

// Affected files



- includes/page_header.php
- templates/<your_template>/user_logininfo.html



// Backup your files

Always backup your files before proceeding to these steps below.

// Step 1

In your includes/page_header.php file,

find :

Quote

// Replace Globals in $lang
$lang = $site_template->parse_array($lang);


add below :

Code: [Select]

if (!empty($user_info['lightbox_image_ids']))  {
  $lightbox_image_ids = explode(" ",$user_info['lightbox_image_ids']);
  $lightbox_total_count = count ($lightbox_image_ids);
}


Then, find :

Quote

"lang_lightbox" => $lang['lightbox'],


add right below :

Code: [Select]

"lightbox_total_count" => intval($lightbox_total_count),


// Step 1.1

Then, find : (updated - automatic refresh when ether removing and adding an image to lightbox).

Quote

$msg = (add_to_lightbox($id)) ? $lang['lightbox_add_success'] : $lang['lightbox_add_error'];


add below :

Code: [Select]

$site_template->register_vars("msg", $msg);


Then, find :

Quote

$msg = (remove_from_lightbox($id)) ? $lang['lightbox_remove_success'] : $lang['lightbox_remove_error'];


add below :

Code: [Select]

$site_template->register_vars("msg", $msg);


This will redirect automatically to your current page and refresh the lightbox count. ;)

// Step 2

In your templates/<your_template>/user_logininfo.html file,

find :

Quote

&raquo; <a href="{url_lightbox}">{lang_lightbox}</a><br />


replace with :

Code: [Select]

&raquo; <a href="{url_lightbox}">{lang_lightbox} ({lightbox_total_count})</a><br />


// Installation complete

That's it. You're done !

To test this out, simply go to your home page gallery as you should be to see the number aside of the lightbox. Add an image to the lightbox and click on the lightbox link (for the first time). Then, you should see the value changing. ;)

For instance : lightbox (1). ;)

(Note: '1' is just an example).

Good luck !

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #1 on: February 09, 2006, 08:00:56 PM »
Update: Step 1.1 added. ;)

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #2 on: February 09, 2006, 09:53:58 PM »
Why an extra query?
I think you can user "explode" to count in $user_info array how many strings are $user_info['lightbox_image_ids'].
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #3 on: February 09, 2006, 10:18:23 PM »
Why an extra query?
I think you can user "explode" to count in $user_info array how many strings are $user_info['lightbox_image_ids'].

I'm not that good yet. That's the only way I figured out above in order to get this working. ;)

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #4 on: February 09, 2006, 10:43:07 PM »
Then do it like this:

Instead of
Code: [Select]
if (!empty($user_info['lightbox_image_ids']))  {
  $image_id_sql = str_replace(" ", ", ", trim($user_info['lightbox_image_ids']));
  $sql = "SELECT COUNT(image_id) AS images
          FROM ".IMAGES_TABLE."
          WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")";
  $result = $site_db->query_firstrow($sql);
  $num_rows_all = $result['images'];

  $lightbox_total_count = str_replace("{lightbox_total_count}", "", $num_rows_all);
}

you can use

Code: [Select]
if (!empty($user_info['lightbox_image_ids']))  {
  $lightbox_image_ids = explode(" ",$user_info['lightbox_image_ids']);
  $lightbox_total_count = count ($lightbox_image_ids);
}

Its a little bit shorter and saves an extra query


Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #5 on: February 09, 2006, 10:46:18 PM »
WORKS! just installed it, thanks :)

Offline artpics

  • Full Member
  • ***
  • Posts: 173
    • View Profile
    • my site
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #6 on: February 09, 2006, 10:52:17 PM »
thanks for giving this mod a new lease of life, i remember this one from a year ago at least, good work  :D

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #7 on: February 09, 2006, 11:29:09 PM »
Quote

if (!empty($user_info['lightbox_image_ids']))  {
  $lightbox_image_ids = explode(" ",$user_info['lightbox_image_ids']);
  $lightbox_total_count = count ($lightbox_image_ids);
}


@icecream:

Thanks. Now I have learned something new. ;)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #8 on: February 10, 2006, 12:46:05 AM »
And why not make the number of "who" have added the picture on details.php  :mrgreen:

Favorite of: XX   :mrgreen:

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #9 on: February 10, 2006, 12:51:52 AM »
Quote

And why not make the number of "who" have added the picture on details.php


And I assume you mean from their profiles ? :roll:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #10 on: February 10, 2006, 12:54:20 AM »
Note, if used Step 1.1 you will not see success or error messages after adding/removing images in/out the lightbox.
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)

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #11 on: February 10, 2006, 01:03:11 AM »
Very well. Step 1.1 has been modified as step 1.2 has just been created.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #12 on: February 10, 2006, 01:21:40 AM »
So, why do you need to refresh the page? just to update the lightbox count? if so, why not just register the lightbox count template tag AFTER image was added/removed? simplier and less server resources used.
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)

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #13 on: February 10, 2006, 01:41:52 AM »
Good point. Step 1.1 has now been re-modified as well as step 1.2 has now been removed.

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: [Feature-addon] - Total count for lightbox (how many images you added).
« Reply #14 on: February 10, 2006, 05:09:56 AM »
Quote

And why not make the number of "who" have added the picture on details.php


And I assume you mean from their profiles ? :roll:


i mean on details.php , below nš of hits , on image page ;)