4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 18, 2014, 10:36:07 AM

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 Issues / Ausgaben
| |-+  Discussion & Troubleshooting (Moderators: Acidgod, ivan, Rembrandt)
| | |-+  how to show my selected pic on index page (home page)
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: how to show my selected pic on index page (home page)  (Read 5424 times)
masumcis
Newbie
*
Offline Offline

Posts: 13

Thank You
-Given: 0
-Receive: 0

Masum


View Profile WWW
« on: February 14, 2008, 12:07:22 PM »

hi,
i want to show some selected (may be 1/2) pic in my home page.
but i dont know how to do it. plz advice me.
i m using 1.7.4 ver
Logged

<<M@sum>>
thunderstrike
4images Guru
*******
Offline Offline

Posts: 2327

Thank You
-Given: 0
-Receive: 10


View Profile
« Reply #1 on: February 14, 2008, 01:25:27 PM »

// Step 1

In index.php file,

find:

1
unset ($new_images);

add after:

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
//-----------------------------------------------------
//--- Selected pic ------------------------------------
//-----------------------------------------------------
if (defined('USE_SELECTED_PIC') && USE_SELECTED_PIC == 1) {

$site_template->register_vars(array(
  "has_rss"   => true,
  "rss_title" => "RSS Feed: ".format_text($config['site_name'], 2)." (".str_replace(':', '', $lang['selected_pic_title']).")",
  "rss_url"   => $script_url."/rss.php?action=images"
));

$imgtable_width = ceil(intval($config['image_table_width']) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
  $imgtable_width .= "%";
}

$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", i.".$key;
  }
}

$num_selected_pic = $config['image_cells'];
$additional_selected_pic_implode = implode(", ", $additional_selected_pics);
$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 i.image_id IN (" . $additional_selected_pic_implode . ") AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
        ORDER BY i.image_date DESC
        LIMIT $num_selected_pic";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $selected_pic = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  $selected_pic .= $lang['no_selected_pic'];
  $selected_pic .= "</td></tr></table>";
}
else  {
  $selected_pic = "<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++ % 2 == 0) ? 1 : 2;
      $selected_pic .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $selected_pic .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

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

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

$site_template->register_vars("selected_pic", $selected_pic);
unset($selected_pic);
}

// Step 2

In includes/db_field_definitions.php file,

add in top ?>:

1
$additional_selected_pics = array("1", "2", "3"); // Each image IDs

// Step 3

In includes/constants.php file,

add in top ?>:

1
define('USE_SELECTED_PIC', 1); // 1 = Active and 0 = no active.

// Step 4

In main/english/main.php file,

add in top ?>:

1
2
$lang['selected_pic_title'] = "Selected pic";
$lang['no_selected_pic'] = "No selected pic";

// Step 5

In includes/page_header.php file,

find:

1
"lang_new_images" => $lang['new_images'],

add after:

1
"lang_selected_pic_title" => $lang['selected_pic_title'],

// Step 6

In templates/your_template/home.html file, use: {if selected_pic}{lang_selected_pic_title}{selected_pic}{endif selected_pic} where you like. Wink

// Is work.

- In includes/constants.php file (USE_SELECTED_PIC define) is for set active / no active in home page.
- In includes/db_field_definitions.php file ($additional_selected_pic array) is for set each image ID you like for select pic. Wink

Finish.

Follow members gave a thank to your post:
niad

For this post, 1 member gave a thank you!
« Last Edit: February 16, 2008, 02:19:32 AM by thunderstrike » Logged

8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?
masumcis
Newbie
*
Offline Offline

Posts: 13

Thank You
-Given: 0
-Receive: 0

Masum


View Profile WWW
« Reply #2 on: February 15, 2008, 12:58:44 PM »

Thank you veeeeeeeeeeeery much. Laughing
Logged

<<M@sum>>
masumcis
Newbie
*
Offline Offline

Posts: 13

Thank You
-Given: 0
-Receive: 0

Masum


View Profile WWW
« Reply #3 on: February 15, 2008, 03:27:27 PM »

hi i did it and it seems nothing happen. no pic on there. what to do. and what will be my images id and where to finr it. Neutral
Logged

<<M@sum>>
thunderstrike
4images Guru
*******
Offline Offline

Posts: 2327

Thank You
-Given: 0
-Receive: 10


View Profile
« Reply #4 on: February 15, 2008, 03:42:11 PM »

Quote  [Expand]
no pic on there. what to do.

ACP - > Categories and check for all setting.
[edit] - I fix step 1. Wink
« Last Edit: February 15, 2008, 05:01:28 PM by thunderstrike » Logged

8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?
masumcis
Newbie
*
Offline Offline

Posts: 13

Thank You
-Given: 0
-Receive: 0

Masum


View Profile WWW
« Reply #5 on: February 15, 2008, 07:47:15 PM »

i chack every thing but igot a error msg like this:

Warning: implode(): Bad arguments. in /home/www/bdpicture/4images_gallery/index.php on line 182

DB Error: Bad SQL Query: 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, c.cat_name, u.user_name FROM (4img_images i, 4img_categories c) LEFT JOIN 4img_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND i.image_id IN () AND c.cat_id = i.cat_id AND i.cat_id NOT IN (0) ORDER BY i.image_date DESC LIMIT 3
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND c.cat_id = i.cat_id AND i.cat_id NOT IN (0) ORDER

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/bdpicture/4images_gallery/includes/db_mysql.php on line 116



what to do Rolling Eyes
Logged

<<M@sum>>
thunderstrike
4images Guru
*******
Offline Offline

Posts: 2327

Thank You
-Given: 0
-Receive: 10


View Profile
« Reply #6 on: February 16, 2008, 02:19:49 AM »

Typo error. Try step 1 again. I fix. Wink
Logged

8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?
masumcis
Newbie
*
Offline Offline

Posts: 13

Thank You
-Given: 0
-Receive: 0

Masum


View Profile WWW
« Reply #7 on: February 17, 2008, 07:26:39 AM »

Thanks, let me chack Laughing
Logged

<<M@sum>>
niad
Jr. Member
**
Offline Offline

Posts: 77

Thank You
-Given: 27
-Receive: 2


View Profile
« Reply #8 on: January 29, 2013, 09:15:07 AM »

Hi,
Is there a way to display more selected pictures?

Now we have:
   $additional_selected_pics = array("1", "2", "3"); // Each image IDs

If I change this to:
        $additional_selected_pics = array("1", "2", "3", "4", "5", "6", "7", "8", "9"); // Each image IDs

still shows only 3 pictures!


OK I found this solution and it works:

$num_selected_pic = 12;
$num_additional_selected_pics = 12;
« Last Edit: January 29, 2013, 10:44:35 AM by niad » Logged

I love 4images, it is really great work!
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.134 seconds with 22 queries.
Post your comments here