4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: TheOracle on February 09, 2006, 05:57:05 PM

Title: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: TheOracle on February 09, 2006, 05:57:05 PM
// 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 !
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: TheOracle on February 09, 2006, 08:00:56 PM
Update: Step 1.1 added. ;)
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: IcEcReaM 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'].
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: TheOracle 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. ;)
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: IcEcReaM 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


Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: trez on February 09, 2006, 10:46:18 PM
WORKS! just installed it, thanks :)
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: artpics 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
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: TheOracle 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. ;)
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: Stoleti 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:
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: TheOracle 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:
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: V@no 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.
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: TheOracle on February 10, 2006, 01:03:11 AM
Very well. Step 1.1 has been modified as step 1.2 has just been created.
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: V@no 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.
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: TheOracle 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.
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: Stoleti 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 ;)
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: IcEcReaM on February 10, 2006, 06:38:13 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 ;)

That would be a new mod,
but i think it would be better that keep this private,
but a number how many users added this picture in their lightbox would be useful.
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: TheOracle on February 10, 2006, 04:32:23 PM
Quote

That would be a new mod


Even better. It could be added as an additional image field with a simple SQL statement. ;)

Quote

how many users added this picture in their lightbox would be useful


For ADMIN level, it would be very useful. I agree. I guess I could try to build this. ;)
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: Stoleti on February 10, 2006, 05:07:09 PM
I don't know if i've explain wrong ....

But i've just said show the number of user's of who have added the image !! Not show their lightboxes ;)
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: TheOracle on February 10, 2006, 05:31:22 PM
Quote

But i've just said show the number of user's of who have added the image !! Not show their lightboxes


Quote

but i think it would be better that keep this private,


Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: IcEcReaM on February 10, 2006, 09:58:31 PM
Even better. It could be added as an additional image field with a simple SQL statement. ;)

I think you don't need a additional field, just search the lightboxes table,
where the image id is added.
But i don't know of the performance,
if it would be really better to add an extra field if you have large gallerys.
Maybe vano could answer it.


how many users added this picture in their lightbox would be useful

ok, thats what i also said, the number would be interesting, but not a list of users,
cause that should be private.

Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: Stoleti on February 10, 2006, 11:06:13 PM
Even better. It could be added as an additional image field with a simple SQL statement. ;)

I think you don't need a additional field, just search the lightboxes table,
where the image id is added.
But i don't know of the performance,
if it would be really better to add an extra field if you have large gallerys.
Maybe vano could answer it.


how many users added this picture in their lightbox would be useful

ok, thats what i also said, the number would be interesting, but not a list of users,
cause that should be private.



yes i've never said "list of users" but yes the number of users of who have added !!!

for example :

Image Hits : 100
Fav's Of     : 12 user(s)


This show just how many , and never "who" , this keep the privacy !! ;) just a simple tool of "stats" for who have upload the pic , maybe "who most popular" between users  :mrgreen:
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: V@no on February 11, 2006, 12:34:58 AM
The way 4images stores images in the lightbox, it will be very expensive on server resources, especialy if you have lots of members with lots of images in their lightboxes...
In this topic you can see that its possible for top.php, but its very not server-friendly:
http://www.4homepages.de/forum/index.php?topic=9033.0
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: IcEcReaM on February 11, 2006, 12:57:16 AM
so in that case it would be better to add like orcale said an extra field to IMAGES TABLE when users add an image to thier light box?
ok, thanks for answer, i assumed already that this would spent to much server ressources
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: urmasmuld on February 19, 2007, 12:00:46 PM
I've installed this MOD. It works perfectly but if i go to search page, it shows :
Undefined variable: lightbox_total_count in /www/01/xxx/xxxx/xxxx/page_header.php on line 159
What could be wrong?

Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: ivan on February 19, 2007, 03:57:21 PM
hi,
the mod is perfekt... only the updatet of lightbox is not perfect.

when i go to index page, is table updating okay
when i go to lightbox.php, the counter is fail

hallo zusammen,
ich habe ein kleines problem mit dem total counter.
wenn ich ein bild unter kategorien oder auf der haupseite hinzufüge,
funktioniert das updating des counters einwandfrei. gehe ich aber zur
lightbox.php, stimmt die zahl nicht mehr mit der paging_stats überein.

wieso?
wer kann helfen...

gruss ivan
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: The Sailor on July 15, 2007, 05:00:14 PM
I've installed this MOD. It works perfectly but if i go to search page, it shows :
Undefined variable: lightbox_total_count in /www/01/xxx/xxxx/xxxx/page_header.php on line 159
What could be wrong?



same problem line:
Code: [Select]
  "lightbox_total_count" => intval($lightbox_total_count),
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: thunderstrike on July 31, 2007, 07:53:05 PM
Here - patch:

http://www.4homepages.de/forum/index.php?topic=17491.msg96772#msg96772
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: urmasmuld on October 09, 2009, 03:34:50 PM
Everything works (for reg. users), but i have installed this [MOD] Lightbox for GUESTs v1.2  (http://www.4homepages.de/forum/index.php?topic=4826), and if not logged in, it shows always i have 0 pics in lightbox. Can any1 tell me what should be modified to get it work for guests too ?
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: V@no on October 09, 2009, 03:44:57 PM
Above the new code you've added from step 1, insert this:
if ($user_info['user_level'] == GUEST) {
    $lightbox = $site_sess->get_session_var('lightbox');
    $user_info['lightbox_image_ids'] = ($lightbox) ? $lightbox : $site_sess->read_cookie_data("lightbox");
    $lightbox = $site_sess->get_session_var('lightbox_lastaction');
    $user_info['lightbox_lastaction'] = ($lightbox) ? $lightbox : $site_sess->read_cookie_data("lightbox_lastaction");
}
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: urmasmuld on October 09, 2009, 03:51:21 PM
Above the new code you've added from step 1, insert this:
if ($user_info['user_level'] == GUEST) {
    $lightbox = $site_sess->get_session_var('lightbox');
    $user_info['lightbox_image_ids'] = ($lightbox) ? $lightbox : $site_sess->read_cookie_data("lightbox");
    $lightbox = $site_sess->get_session_var('lightbox_lastaction');
    $user_info['lightbox_lastaction'] = ($lightbox) ? $lightbox : $site_sess->read_cookie_data("lightbox_lastaction");
}

Wow, that was quick, and it works now. Thanks V@no, u saved my day :D
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: wingnut on November 02, 2009, 07:52:42 PM
I've tried using this, and for some reason, the page is not refreshing after the first add, only after the second add, so the total is always one less than it should be.

For example, I add the first image to the lightbox, and the count remains 0. As soon as I add the second image to the lightbox, the count goes to 1, but clicking on the lightbox, there are clearly 2 images there. Any idea what is wrong? I've double and triple checked my edits, and all is correct. Using 1.7.7
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: urmasmuld on November 11, 2009, 01:05:09 PM
I've tried using this, and for some reason, the page is not refreshing after the first add, only after the second add, so the total is always one less than it should be.

For example, I add the first image to the lightbox, and the count remains 0. As soon as I add the second image to the lightbox, the count goes to 1, but clicking on the lightbox, there are clearly 2 images there. Any idea what is wrong? I've double and triple checked my edits, and all is correct. Using 1.7.7

Same prob. here. Anyone knows how to fix it ?
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: V@no on November 11, 2009, 03:15:08 PM
Remove ALL modifications from step 1 and 1.1

In includes/page_header.php find:
//-----------------------------------------------------
//--- User Box ----------------------------------------
//-----------------------------------------------------


Insert above:
$site_template->register_vars("lightbox_total_count", (empty($user_info['lightbox_image_ids']) ? 0 : count(explode(" ", trim($user_info['lightbox_image_ids'])))));
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: urmasmuld on November 25, 2009, 05:24:10 PM
wow, it works now. Thanx again V@no  :lol:
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: urmasmuld on March 22, 2010, 06:35:56 PM
I have tried installing this : Topic: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29) (http://www.4homepages.de/forum/index.php?topic=5321.0)

Is it possible to refresh lightbox count aswell, like this lightbox button ?

EDIT : got it work somehow. It now refreshes whole page, but it wont go top of the page after refresh ;) (EDIT 2: it will work like this in FF only, in IE it goes top of page  :roll:)

changed in functions.php

Code: [Select]
    $lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\" onclick=\"this.firstChild.src='".$site_sess->url(ROOT_PATH."lightboxaction.php?id=".$image_row['image_id'])."&ilu='+this.firstChild.src; return false;\"><img src=\"".get_gallery_image("lightbox_yes.gif")."\" border=\"0\" alt=\"\" /></a>";

to this
Code: [Select]
    $lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\" onclick=\"this.firstChild.src='".$site_sess->url(ROOT_PATH."lightboxaction.php?id=".$image_row['image_id'])."&ilu='+this.firstChild.src; window.location.reload(); return false;\"><img src=\"".get_gallery_image("lightbox_yes.gif")."\" border=\"0\" alt=\"\" /></a>";

and this code

Code: [Select]
    $lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\" onclick=\"this.firstChild.src='".$site_sess->url(ROOT_PATH."lightboxaction.php?id=".$image_row['image_id'])."&ilu='+this.firstChild.src; return false;\"><img src=\"".get_gallery_image("lightbox_no.gif")."\" border=\"0\" alt=\"\" /></a>";

into this :

Code: [Select]
    $lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\" onclick=\"this.firstChild.src='".$site_sess->url(ROOT_PATH."lightboxaction.php?id=".$image_row['image_id'])."&ilu='+this.firstChild.src; window.location.reload(); return false;\"><img src=\"".get_gallery_image("lightbox_no.gif")."\" border=\"0\" alt=\"\" /></a>";

tried to surround {lightbox_total_count} with DIV tags, but refreshing DIV needs another page inside DIV (http://www.google.com/search?q=onclick+refresh+div) (ex. lightbox_total_count.php), as I understand. If we could make a page which showing {lightbox_total_count} inside it would be cool and then could refresh it without refreshing whole page.

EDIT3 : got it to work ;)
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: Geezer on June 01, 2015, 09:37:17 AM
Remove ALL modifications from step 1 and 1.1

In includes/page_header.php find:
//-----------------------------------------------------
//--- User Box ----------------------------------------
//-----------------------------------------------------


Insert above:
$site_template->register_vars("lightbox_total_count", (empty($user_info['lightbox_image_ids']) ? 0 : count(explode(" ", trim($user_info['lightbox_image_ids'])))));



Does it work with uploads? I have in the Userbox "uploads" and i need it.

Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: Geezer on June 05, 2015, 08:28:52 PM
means no answer that it does not work??
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: Rembrandt on June 10, 2015, 03:57:15 PM
means no answer that it does not work??
What do you want, this Mod count only the Images from Lightbox and display it in the User Box.
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: Geezer on June 11, 2015, 01:53:00 PM
I have in Userbox also upload (see image).  there I would also like the counter
Title: Re: [Feature-addon] - Total count for lightbox (how many images you added).
Post by: Rembrandt on June 11, 2015, 06:26:46 PM
search in includes/page_header.php:

if (isset($array[$file])) {
  $array[$file] = true;
}

insert above:

 //############## Start Count User Images ############
    $sql = "SELECT COUNT(image_id) AS sum_images
            FROM ".IMAGES_TABLE."
            WHERE image_active = 1  AND user_id = ".$user_info['user_id']."
            ";
    $sum_images = $site_db->query_firstrow($sql);
//############## End Count Images ###################

search:

$site_template->register_vars(array(
  "home_url"  => ROOT_PATH,

insert below:

   "count_user_images" => $sum_images['sum_images'],

in "your template/user_logininfo.html", wherever you want :
Code: [Select]
{count_user_images}