4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 31, 2014, 01:02:21 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 (Releases & Support) (Moderators: mawenzi, Rembrandt)
| | |-+  [Mod] How to display 6 top rated images of last week in home page ?
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Current Topic Rating: *****
Author Topic: [Mod] How to display 6 top rated images of last week in home page ?  (Read 8939 times)
pjotrek
Newbie
*
Offline Offline

Posts: 24

Thank You
-Given: 1
-Receive: 3


View Profile
« on: July 03, 2012, 03:52:50 PM »

Hello

How Can i Display on home page 6 top rated images of last week ?

Logged
Rembrandt
Moderator
4images Guru
*****
Offline Offline

Posts: 4089

Thank You
-Given: 108
-Receive: 860

Vienna


View Profile WWW
« Reply #1 on: July 04, 2012, 06:18:22 PM »

Hi!

It was not as easy as I thought...

1.) search in your templates/home.html:
1
{whos_online}
insert above, or where ever you want:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
                 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="4">
                          <tr>
                            <td class="head1" valign="top">Top images last week</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                    <tr>
                      <td class="head1">{last_week}</td>
                    </tr>
                  </table>
                 <br>

2.) search in index.php:
1
$num_new_images $config['image_cells'];
insert above:
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
function getDaysInWeek($week="",$year=""){  
  
$year = ($year) ? $year date("Y");
  
$week = ($week) ? $week date("W");
  
$time strtotime($year.'0104+'.($week 1).'weeks');
  
$mondayTime strtotime('-'.(date('w',$time)-1).'days',$time);
  
$dayTimes = array(); 
  for (
$i 0$i 7;++$i){ 
    
$dayTimes[] = strtotime('+'.$i.'days'$mondayTime); 
    
//$dayTimes[] = date("d.m.Y",strtotime('+'.$i.'days', $mondayTime));
  

  return 
$dayTimes
}
$lastweek date("W") -1;
$weekday getDaysInWeek($lastweek);

$num_new_images $config['image_cells'];
$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 NOT IN ("
.get_auth_cat_sql("auth_viewcat""NOTIN").") AND i.image_date BETWEEN ".$weekday[0]." AND ".($weekday[6] + 86399)."
        ORDER BY i.image_rating DESC
        LIMIT 
$num_new_images
        "
;
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$last_week "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  
$last_week .= "No Images last week !";
  
$last_week .= "</td></tr></table>";
}
else  {
  
$last_week "<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;
      
$last_week .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$last_week .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

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

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

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

mfg Andi
« Last Edit: July 30, 2012, 10:40:20 AM by Rembrandt » Logged

Meine 4Images Modifikationen  Now over 100 Modification Online!    Meine 4images Demo Seite


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

Posts: 24

Thank You
-Given: 2
-Receive: 3


View Profile
« Reply #2 on: July 30, 2012, 10:35:16 AM »

I did exactly what you said but i got error message
Quote  [Expand]
Parse error: syntax error, unexpected T_VARIABLE, expecting ';' in /home/content/73/8131873/html/index.php on line 285

please help me to solve it

thanks
Logged
Rembrandt
Moderator
4images Guru
*****
Offline Offline

Posts: 4089

Thank You
-Given: 108
-Receive: 860

Vienna


View Profile WWW
« Reply #3 on: July 30, 2012, 10:39:12 AM »

sry...
search:
1
unset($last_week)
and replace:
1
unset($last_week);

mfg Andi
Logged

Meine 4Images Modifikationen  Now over 100 Modification Online!    Meine 4images Demo Seite


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)
niad
Jr. Member
**
Offline Offline

Posts: 77

Thank You
-Given: 27
-Receive: 2


View Profile
« Reply #4 on: November 17, 2012, 08:05:14 AM »

Hi Rebrandt  Smile

Is it possible to manipulate the above script, to show "Yesterdays Top" instead of 7 days top?
What should I change?   Rolling Eyes
Logged

I love 4images, it is really great work!
Rembrandt
Moderator
4images Guru
*****
Offline Offline

Posts: 4089

Thank You
-Given: 108
-Receive: 860

Vienna


View Profile WWW
« Reply #5 on: November 17, 2012, 04:47:46 PM »

Hi!
... to show "Yesterdays Top" instead of 7 days top?
...

search in the code:
1
$num_new_images $config['image_cells'];
insert above:
1
2
$start_yesterday mktime(00,00,00,date("m"),date("d")-1,date("Y")); 
$end_yesterday mktime(23,59,59,date("m"),date("d")-1,date("Y"));
search:
1
WHERE i.image_active AND c.cat_id i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").") AND i.image_date BETWEEN ".$weekday[3]." AND ".($weekday[4] + 86399)."
and replace:
1
WHERE i.image_active AND c.cat_id i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").") AND i.image_date BETWEEN ".$start_yesterday." AND ".$end_yesterday."

mfg Andi
Logged

Meine 4Images Modifikationen  Now over 100 Modification Online!    Meine 4images Demo Seite


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)
niad
Jr. Member
**
Offline Offline

Posts: 77

Thank You
-Given: 27
-Receive: 2


View Profile
« Reply #6 on: November 18, 2012, 06:13:09 PM »

You are a treasure dear Rembrandt!!! Thank you so much, it works great!!! Very Happy
Logged

I love 4images, it is really great work!
Szooguun
Newbie
*
Offline Offline

Posts: 32

Thank You
-Given: 4
-Receive: 0


View Profile
« Reply #7 on: November 18, 2012, 06:14:27 PM »

Welcome. How to modify the mod to display the most viewed photos in the last week?
Logged
Rembrandt
Moderator
4images Guru
*****
Offline Offline

Posts: 4089

Thank You
-Given: 108
-Receive: 860

Vienna


View Profile WWW
« Reply #8 on: November 18, 2012, 06:30:12 PM »

Hi!
Welcome. How to modify the mod to display the most viewed photos in the last week?

search:
1
ORDER BY i.image_rating DESC
and replace:
1
ORDER BY i.image_hits DESC

mfg Andi
Logged

Meine 4Images Modifikationen  Now over 100 Modification Online!    Meine 4images Demo Seite


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)
ASAD
Jr. Member
**
Offline Offline

Posts: 59

Thank You
-Given: 8
-Receive: 4


View Profile WWW
« Reply #9 on: November 26, 2012, 12:12:52 PM »

Hi, hab das mod (the most viewed photos) eingebaut aber zeigt nur ein bild
Logged

wallward
Jr. Member
**
Offline Offline

Posts: 53

Thank You
-Given: 275
-Receive: 0


View Profile
« Reply #10 on: March 05, 2014, 09:15:07 AM »

excellence  Very Happy
How to extended to show last Month Top?
Rembrandt if possible please answer Sad
Logged

Rembrandt
Moderator
4images Guru
*****
Offline Offline

Posts: 4089

Thank You
-Given: 108
-Receive: 860

Vienna


View Profile WWW
« Reply #11 on: March 05, 2014, 06:28:52 PM »

last Month
1.) search in the HTML code {last_week} and replace with {last_month}
2.) replace the PHP code with this one:
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
$startTime mktime(000date("m")-11date("Y"));
$endTime mktime(000date("m"), 0date("Y"));
$num_new_images $config['image_cells'];
$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 NOT IN ("
.get_auth_cat_sql("auth_viewcat""NOTIN").") AND i.image_date BETWEEN ".$startTime." AND ".$endTime."
        ORDER BY i.image_rating DESC
        LIMIT 
$num_new_images
        "
;
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$last_month "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  
$last_month .= "No Images last week !";
  
$last_month .= "</td></tr></table>";
}
else  {
  
$last_month "<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;
      
$last_month .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$last_month .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

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

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

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

mfg Andi
Logged

Meine 4Images Modifikationen  Now over 100 Modification Online!    Meine 4images Demo Seite


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)
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.139 seconds with 21 queries.