4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started 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 :
// Replace Globals in $lang
$lang = $site_template->parse_array($lang);
add below :
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 :
"lang_lightbox" => $lang['lightbox'],
add right below :
"lightbox_total_count" => intval($lightbox_total_count),
// Step 1.1
Then, find : (updated - automatic refresh when ether removing and adding an image to lightbox).
$msg = (add_to_lightbox($id)) ? $lang['lightbox_add_success'] : $lang['lightbox_add_error'];
add below :
$site_template->register_vars("msg", $msg);
Then, find :
$msg = (remove_from_lightbox($id)) ? $lang['lightbox_remove_success'] : $lang['lightbox_remove_error'];
add below :
$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 :
» <a href="{url_lightbox}">{lang_lightbox}</a><br />
replace with :
» <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 !
-
Update: Step 1.1 added. ;)
-
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'].
-
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. ;)
-
Then do it like this:
Instead of
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
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
-
WORKS! just installed it, thanks :)
-
thanks for giving this mod a new lease of life, i remember this one from a year ago at least, good work :D
-
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. ;)
-
And why not make the number of "who" have added the picture on details.php :mrgreen:
Favorite of: XX :mrgreen:
-
And why not make the number of "who" have added the picture on details.php
And I assume you mean from their profiles ? :roll:
-
Note, if used Step 1.1 you will not see success or error messages after adding/removing images in/out the lightbox.
-
Very well. Step 1.1 has been modified as step 1.2 has just been created.
-
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.
-
Good point. Step 1.1 has now been re-modified as well as step 1.2 has now been removed.
-
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 ;)
-
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.
-
That would be a new mod
Even better. It could be added as an additional image field with a simple SQL statement. ;)
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. ;)
-
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 ;)
-
But i've just said show the number of user's of who have added the image !! Not show their lightboxes
but i think it would be better that keep this private,
-
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.
-
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:
-
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
-
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
-
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?
-
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:
"lightbox_total_count" => intval($lightbox_total_count),
-
Here - patch:
http://www.4homepages.de/forum/index.php?topic=17491.msg96772#msg96772
-
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 ?
-
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");
}
-
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
-
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
-
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 ?
-
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'])))));
-
wow, it works now. Thanx again V@no :lol:
-
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
$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
$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
$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 :
$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 ;)
-
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.
-
means no answer that it does not work??
-
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.
-
I have in Userbox also upload (see image). there I would also like the counter
-
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 :
{count_user_images}