4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 18, 2018, 09:42:26 PM

Login with username, password and session length
Search:     Advanced search
Check the new Tutorial subforum with helpfull guides and tutorials for modifications and tweaks.
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Requests & Discussions) (Moderators: mawenzi, Rembrandt)
| | |-+  Random pictures
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 3 4 5 ... 10 » »» Print
Author Topic: Random pictures  (Read 162279 times)
joecks
Newbie
*
Offline Offline

Posts: 11

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« on: February 21, 2003, 06:48:49 PM »

Hi all,

Is it possible to add a section "random Images" on the index page, below or above the new pictures ? and a section "most popular" ???

I have that option in photopost pro, but this program is not working when safe mode is on  Crying or Very sad (shame for a $149 product !) , thats why is use the great free program 4images now.

Great Program!

Grtx,

Joecks
Logged
SLL
Hero Member
*****
Offline Offline

Posts: 585

Thank You
-Given: 0
-Receive: 2


View Profile
« Reply #1 on: February 21, 2003, 10:34:52 PM »

"random picture" is already there by default, the "most popular" you can find in the this forum, in mod's section (photo of the day)
Logged
joecks
Newbie
*
Offline Offline

Posts: 11

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #2 on: February 22, 2003, 09:26:32 AM »

I know there is a random picture, but i want to know if it is posible to ad random pictures on the index page below or above the new images, not just 1 random picture but as many as the new pictures..

same for the most popular pictures.

for a example see this featured site of photopost, http://www.spymac.com/gallery/

than you see what i mean.

Thanx

Carlo
Logged
SLL
Hero Member
*****
Offline Offline

Posts: 585

Thank You
-Given: 0
-Receive: 2


View Profile
« Reply #3 on: February 22, 2003, 11:55:08 AM »

if you mean showing random pics at any page, not inside 4images - this mod you also can find in mod's section of this forum
Logged
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 577

mmm PHP...


View Profile WWW
« Reply #4 on: February 22, 2003, 01:52:15 PM »

Open index.php
Find:
1
2
$site_template->register_vars("new_images", $new_images);
unset($new_images);

Add after:

Version A (without cache, images will be randomize on each visit, each page refresh)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//------------------------------------
//------- Random Images --------------
//------------------------------------
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
        FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN ("
.get_auth_cat_sql("auth_viewcat").")
        ORDER BY RAND()
        LIMIT 
$num_new_images";
// end new
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images .= $lang['no_new_images'];
  
$random_images .= "</td></tr></table>";
}
else  {
  
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  
$count 0;
  
$bgcounter 0;
  while (
$image_row $site_db->fetch_array($result)){
    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
      
$random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    
show_image($image_row);
    
$random_images .= $site_template->parse_template("thumbnail_bit");
    
$random_images .= "\n</td>\n";
    
$count++;
    if (
$count == $config['image_cells']) {
      
$random_images .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['image_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      
$random_images .= "</tr>\n";
    }
  }
  
$random_images .= "</table>\n";
// end else


$site_template->register_vars("random_images"$random_images);
unset(
$random_images);

//----- End Random Images---------

Version B (with cache, images will be randomize once each hour, time controlled by $cache_time on top of the code.)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//------------------------------------
//------- Random Images --------------
//------------------------------------
$cache_time 3600//3600sek = 1hour

$cache_enable_old $cache_enable;
$cache_enable true;
$cache_id_rand create_cache_id(
  
'page.rand',
  array(
    
$user_info[$user_table_fields['user_id']],
    isset(
$user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 08) : 0,
    
$config['template_dir'],
    
$config['language_dir']
  )
);
if (!
$random_images get_cache_file($cache_id_rand$cache_time))
{
  
// Always append session id if cache is enabled
  
$old_session_mode $site_sess->mode;
  
$site_sess->mode 'get';
  
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
          FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
          LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
          WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN ("
.get_auth_cat_sql("auth_viewcat").")
          ORDER BY RAND()
          LIMIT 
$num_new_images";
  
// end new
  
$result $site_db->query($sql);
  
$num_rows $site_db->get_numrows($result);
  
  if (!
$num_rows)  {
    
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  
//  $random_images .= $lang['no_new_images'];
    
$random_images .= "</td></tr></table>";
  }
  else  {
    
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
    
$count 0;
    
$bgcounter 0;
    while (
$image_row $site_db->fetch_array($result)){
      if (
$count == 0) {
        
$row_bg_number = ($bgcounter++ % == 0) ? 2;
        
$random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
      }
      
$random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
  
      
show_image($image_row);
      
$random_images .= $site_template->parse_template("thumbnail_bit");
      
$random_images .= "\n</td>\n";
      
$count++;
      if (
$count == $config['image_cells']) {
        
$random_images .= "</tr>\n";
        
$count 0;
      }
    } 
// end while
  
    
if ($count 0)  {
      
$leftover = ($config['image_cells'] - $count);
      if (
$leftover >= 1) {
        for (
$f 0$f $leftover$f++) {
          
$random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
        }
        
$random_images .= "</tr>\n";
      }
    }
    
$random_images .= "</table>\n";
  } 
// end else
  
$site_sess->mode $old_session_mode;
  
save_cache_file($cache_id_rand$random_images);
}
$cache_enable $cache_enable_old;
$site_template->register_vars("random_images"$random_images);
unset(
$random_images);

//----- End Random Images---------


Now, in home.html template add {random_images}

Follow members gave a thank to your post:
wallward, zimba

For this post, 2 members gave a thank you!
« Last Edit: November 24, 2009, 03:05:31 PM by V@no » Logged

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)
SLL
Hero Member
*****
Offline Offline

Posts: 585

Thank You
-Given: 0
-Receive: 2


View Profile
« Reply #5 on: February 22, 2003, 04:44:43 PM »

ah.. that's what he wanted  Rolling Eyes
Logged
Chris
4images Moderator
4images Guru
*****
Offline Offline

Posts: 4487

Thank You
-Given: 0
-Receive: 31

Did u ever stop to think and then forget to start?


View Profile
« Reply #6 on: February 22, 2003, 04:57:13 PM »

Quote from: V@no   [Expand]
Now, in home.html template add {random_images}

Laughing

V@no I should hire you to finish the rest of the coding for my web site so I can get back to photography !
Logged

joecks
Newbie
*
Offline Offline

Posts: 11

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #7 on: February 22, 2003, 05:34:03 PM »

Very Happy Thank you very much v@no, it works... great!!!

Only one question left  Embarassed

How do you put the title "random Images" above the random images.

I hope it is no stupid question.... .

Greetings Joecks
Logged
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 577

mmm PHP...


View Profile WWW
« Reply #8 on: February 22, 2003, 05:51:05 PM »

Quote from: joecks   [Expand]
Very Happy Thank you very much v@no, it works... great!!!
Only one question left  Embarassed
How do you put the title "random Images" above the random images.
I hope it is no stupid question.... .
Greetings Joecks

I the code I posted, change:
1
2
$site_template->register_vars("random_images", $random_images);
unset($random_images);

to this:
1
2
3
4
5
$site_template->register_vars(array(
"random_images" => $random_images,
"lang_random_images" => $lang['random_images']
));
unset($random_images);


Then, open /lang/<yourlanguage>/main.php
and at the end of the file, just before ?> add this:
1
$lang['random_images'] = "Random Images";

now u can use this tag in the template: {lang_random_images}

Follow members gave a thank to your post:
wallward

For this post, 1 member gave a thank you!
Logged

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)
joecks
Newbie
*
Offline Offline

Posts: 11

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #9 on: February 22, 2003, 05:58:45 PM »

@ V@no ,

You are the best !!!

Now it works great !!

Greetings

Carlo
Logged
uny
Newbie
*
Offline Offline

Posts: 46

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #10 on: February 24, 2003, 03:41:48 PM »

cool..that's what I want too, thanks V@no
Logged
Bomba
Full Member
***
Offline Offline

Posts: 202

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #11 on: March 09, 2003, 08:49:05 PM »

i used this code and it works just great
but there's something that i would like to change, if possible.

with this code it shows the same number of random images as the new images, but i would like to show only 6 random images.

my index shows 2 rows of new images (12 new images) and for the random images i just want 1 row (6 images)


thanks
Logged
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 577

mmm PHP...


View Profile WWW
« Reply #12 on: March 09, 2003, 09:33:52 PM »

Quote from: Bomba   [Expand]
with this code it shows the same number of random images as the new images, but i would like to show only 6 random images.

my index shows 2 rows of new images (12 new images) and for the random images i just want 1 row (6 images)

on top of the code I posted (before/above the code), add this line:
1
$num_new_images = $config['image_cells'];
Logged

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)
Bomba
Full Member
***
Offline Offline

Posts: 202

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #13 on: March 09, 2003, 10:33:51 PM »

thanks Smile

that was just what i wanted
Logged
Kamui
Newbie
*
Offline Offline

Posts: 19

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #14 on: March 12, 2003, 05:35:33 PM »

hi. i wannit to show 15 images in 3 lines, thus 5 per line. howa do this?
thx
Logged
Pages: [1] 2 3 4 5 ... 10 » »» Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.085 seconds with 23 queries.