Author Topic: how to show my selected pic on index page (home page)  (Read 10637 times)

0 Members and 1 Guest are viewing this topic.

Offline masumcis

  • Newbie
  • *
  • Posts: 13
  • Masum
    • View Profile
    • Photo Gallery
how to show my selected pic on index page (home page)
« 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
<<M@sum>>

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: how to show my selected pic on index page (home page)
« Reply #1 on: February 14, 2008, 01:25:27 PM »
// Step 1

In index.php file,

find:

Code: [Select]
unset ($new_images);

add after:

Code: [Select]
//-----------------------------------------------------
//--- 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 ?>:

Code: [Select]
$additional_selected_pics = array("1", "2", "3"); // Each image IDs

// Step 3

In includes/constants.php file,

add in top ?>:

Code: [Select]
define('USE_SELECTED_PIC', 1); // 1 = Active and 0 = no active.

// Step 4

In main/english/main.php file,

add in top ?>:

Code: [Select]
$lang['selected_pic_title'] = "Selected pic";
$lang['no_selected_pic'] = "No selected pic";

// Step 5

In includes/page_header.php file,

find:

Code: [Select]
"lang_new_images" => $lang['new_images'],

add after:

Code: [Select]
"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. ;)

// 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. ;)

Finish.
« Last Edit: February 16, 2008, 02:19:32 AM by thunderstrike »
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 ?

Offline masumcis

  • Newbie
  • *
  • Posts: 13
  • Masum
    • View Profile
    • Photo Gallery
Re: how to show my selected pic on index page (home page)
« Reply #2 on: February 15, 2008, 12:58:44 PM »
Thank you veeeeeeeeeeeery much. :lol:
<<M@sum>>

Offline masumcis

  • Newbie
  • *
  • Posts: 13
  • Masum
    • View Profile
    • Photo Gallery
Re: how to show my selected pic on index page (home page)
« 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. :|
<<M@sum>>

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: how to show my selected pic on index page (home page)
« Reply #4 on: February 15, 2008, 03:42:11 PM »
Quote
no pic on there. what to do.

ACP - > Categories and check for all setting.
[edit] - I fix step 1. ;)
« Last Edit: February 15, 2008, 05:01:28 PM by thunderstrike »
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 ?

Offline masumcis

  • Newbie
  • *
  • Posts: 13
  • Masum
    • View Profile
    • Photo Gallery
Re: how to show my selected pic on index page (home page)
« 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 :roll:
<<M@sum>>

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: how to show my selected pic on index page (home page)
« Reply #6 on: February 16, 2008, 02:19:49 AM »
Typo error. Try step 1 again. I fix. ;)
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 ?

Offline masumcis

  • Newbie
  • *
  • Posts: 13
  • Masum
    • View Profile
    • Photo Gallery
Re: how to show my selected pic on index page (home page)
« Reply #7 on: February 17, 2008, 07:26:39 AM »
Thanks, let me chack :lol:
<<M@sum>>

Offline niad

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: how to show my selected pic on index page (home page)
« 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 »
I love 4images, it is really great work!