4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 21, 2014, 08:21:02 PM

Login with username, password and session length
Search:     Advanced search
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] Most Popular, Most Votes and Most Recent
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
This topic has not yet been rated!
Author Topic: [MOD] Most Popular, Most Votes and Most Recent  (Read 10855 times)
scubaguy
Pre-Newbie

Offline Offline

Posts: 8

Thank You
-Given: 0
-Receive: 1


View Profile
« on: October 21, 2005, 11:35:08 PM »

I am working on a site that needed three seperate modules showing the Most Recent, the Most Popular and Top Votes.

Here is the code for the Most Recent:

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
<?php // PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH''../');
  global 
$site_db$cat_cache$total_images;


// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images 5;

$sql "SELECT a.image_id, a.cat_id, a.image_name, a.image_date, a.image_active, a.image_thumb_file, a.image_comments
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
        WHERE a.image_active=1
        AND a.cat_id = b.cat_id
AND a.cat_id != 23
        AND b.auth_viewcat="
.AUTH_ALL."
        AND b.auth_viewimage="
.AUTH_ALL."
        ORDER BY a.image_date DESC
        LIMIT 
$num_images";
$result $site_db->query($sql);

if (
$result) {
while (
$row $site_db->fetch_array($result)) {
  
$image_id $row['image_id'];
  
$cat_id $row['cat_id'];
  
$image_name $row['image_name'];
  
$image_comments $row['image_comments'];
  
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

  echo 
"<div style='float:left;width:66px;height:68px;margin:3px;padding-bottom:4px;'><div style='border:2px solid #ffffff;width:64px;height:64px;'><a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\" width=\"64\" height=\"64\"></div>\n";
  echo 
ShortenText($image_name)."\n";
echo "</div>\n";
}
}
?>

Here is the code for Most Popular:

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
<?php // PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH''../');
  global 
$site_db$cat_cache$total_images;

// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images 12;

$sql "SELECT a.image_id, a.cat_id, a.image_name, a.image_hits, a.image_active, a.image_thumb_file, a.image_comments
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
        WHERE a.image_active=1
        AND a.cat_id = b.cat_id
AND a.cat_id != '23'
        AND b.auth_viewcat="
.AUTH_ALL."
        AND b.auth_viewimage="
.AUTH_ALL."
        ORDER BY a.image_hits DESC
        LIMIT 
$num_images";
$result $site_db->query($sql);

if (
$result) {
while (
$row $site_db->fetch_array($result)) {
  
$image_id $row['image_id'];
  
$cat_id $row['cat_id'];
  
$image_name $row['image_name'];
  
$image_comments $row['image_comments'];
  
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

  echo 
"<div style='float:left;width:66px;height:68px;margin:3px;'><div style='border:2px solid #f2f2f2;width:64px;height:64px;'><a href=\"".ROOT_PATH."details.php?image_id=$image_id\" title=\"$image_name\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"  width='64' height='64'><br>\n";
echo "</div></div>\n";
}
}
?>

Here is the code for the Top Votes:

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
<?php // PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH''../');
  global 
$site_db$cat_cache$total_images;

// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images 8;

$sql "SELECT DISTINCT a.image_id, a.cat_id, a.image_name, a.image_votes, a.image_active, a.image_thumb_file, a.image_comments, a.image_description, a.image_date
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
        WHERE a.image_active=1
AND a.cat_id = '23'
        ORDER BY a.image_date DESC
        LIMIT 
$num_images";
$result $site_db->query($sql);
if (
$result) {
while (
$row $site_db->fetch_array($result)) {
  
$image_id $row['image_id'];
  
$cat_id $row['cat_id'];
$image_description $row['image_description'];
  
$image_name $row['image_name'];
  
$image_comments $row['image_comments'];
  
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

  echo 
"<div style='float:left;width:66px;height:68px;margin:3px;'><div style='border:2px solid #f2f2f2;width:64px;height:64px;'><a href=\"$image_description\" title=\"$image_name\" target=\"_blank\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\" width='64' height='64'><br>\n";
echo "</div></div>\n";
}
}
?>
Logged
scubaguy
Pre-Newbie

Offline Offline

Posts: 8

Thank You
-Given: 0
-Receive: 1


View Profile
« Reply #1 on: October 21, 2005, 11:36:51 PM »

I also need to add a function to shorten the length of the image name in functions.php

1
2
3
4
5
6
7
8
9
10
11
12
13
    function ShortenText($text) {

        // Change to the number of characters you want to display
        $chars = 10;

        $text = $text." ";
        $text = substr($text,0,$chars);
        $text = substr($text,0,strrpos($text,' '));
        $text = $text."";

        return $text;

    }
Logged
scubaguy
Pre-Newbie

Offline Offline

Posts: 8

Thank You
-Given: 0
-Receive: 1


View Profile
« Reply #2 on: January 12, 2006, 08:11:44 AM »

This code was working, but now that I've tried it with 1.7.1 with the security patches it has stopped working.  Absolutely nothing is displayed, not even error messages.  Does anyone know what might be the problem?

I also noticed that when I try to create SEO urls with $site_sess->url they are no longer being converted.  Did something change that I am not aware of.  It all used to work.   Sad
Logged
botakedan
Pre-Newbie

Offline Offline

Posts: 3

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #3 on: October 13, 2006, 01:57:20 PM »

i am using 4images 1.7.2
can you teach me where i should put that scripts ???
Logged
quartz
Newbie
*
Offline Offline

Posts: 18

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #4 on: February 23, 2007, 05:19:49 PM »

change this
1
define('ROOT_PATH', '../');

I replace with this
1
2
3
4
5
6
7
8
define('ROOT_PATH', './');
include(ROOT_PATH.'config.php');
include(ROOT_PATH.'includes/db_mysql.php');
include(ROOT_PATH.'includes/constants.php');
$site_db = new Db($db_host, $db_user, $db_password, $db_name);
function is_remote($file_name) {
  return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $file_name)) ? 1 : 0;
}

that worked for me
Logged
a1367h
Pre-Newbie

Offline Offline

Posts: 5

Thank You
-Given: 2
-Receive: 1


View Profile
« Reply #5 on: December 20, 2012, 02:24:22 AM »

Hi.
I'm using 1.7.11 . I want to know where i have to put these code to show in home page.
please help. I need this mod.
Logged

Hossein Rad
wallward
Jr. Member
**
Offline Offline

Posts: 52

Thank You
-Given: 273
-Receive: 0


View Profile
« Reply #6 on: February 18, 2014, 01:50:59 PM »

Where do I put this code?
how to Show result in Home page?  Question
Logged

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.25 seconds with 20 queries.
Post your comments here