Author Topic: [MOD] - Today upload image - gallery index page  (Read 4006 times)

0 Members and 1 Guest are viewing this topic.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
[MOD] - Today upload image - gallery index page
« on: January 14, 2008, 12:38:55 AM »
This is MOD for see all upload today image in gallery index page (paging include). ;)

// Step 1

In index.php file,

find:

Code: [Select]
$site_template->register_vars("new_images", $new_images);
unset($new_images);

add after:

Code: [Select]
//-----------------------------------------------------
//--- Show Today Images -------------------------------
//-----------------------------------------------------

$today_images = time() - 60 * 60 * 24 * 1;
$sql = "SELECT COUNT(*) AS num_rows_all
        FROM (" . IMAGES_TABLE . " i, " . CATEGORIES_TABLE . " c)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.image_date >= " . $today_images . " AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
        ";
       
$row = $site_db->query_firstrow($sql);
$num_rows_all = (isset($row['num_rows_all'])) ? $row['num_rows_all'] : 0;

$link_arg = $site_sess->url(ROOT_PATH."index.php");

include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $perpage, $num_rows_all, $link_arg);
$offset = $getpaging->get_offset();
$site_template->register_vars(array(
  "paging" => $getpaging->get_paging(),
  "paging_stats" => (isset($num_rows_all) && $num_rows_all > 0) ? $getpaging->get_paging_stats() : ""
));


$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;
  }
}

$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.image_date >= " . $today_images . " AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
        ORDER BY i.image_date DESC
        LIMIT " . $offset . ", " . $perpage;
       
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

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

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

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

$site_template->register_vars("today_images", $today_new_images);
unset($today_new_images);

// Step 2

In includes/page_header.php file,

find:

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

add after:

Code: [Select]
"lang_today_images" => $lang['today_images'],

// Step 3

In lang/english/main.php file,

find:

Code: [Select]
$lang['new_images'] = "New images";

add after:

Code: [Select]
$lang['today_images'] = "Today images";
$lang['no_today_images'] = "There are no daily images at this time.";

// Step 4

In templates/your_template/home.html file,

find:

Code: [Select]
<tr>
                      <td class="head1">{new_images}</td>
                    </tr>                   
                  </table>

add after:

Code: [Select]
{if today_images}
                  <br />
                   <table width="450" 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">{lang_today_images}</td>
                          </tr>
                        </table>
                        {if paging_stats}
                        <table width="100%" border="0" cellspacing="0" cellpadding="4">
                          <tr>
                            <td class="row2" valign="top" align="center"><br />{paging_stats}<br /><br /></td>
                          </tr>                         
                        </table>
                        {endif paging_stats}
                        {if paging}
                        <table width="100%" border="0" cellspacing="0" cellpadding="4">
                          <tr>
                            <td class="row2" valign="top" align="right">{paging}&nbsp;</td>
                          </tr>                         
                        </table>
                        {endif paging}
                      </td>
                    </tr>
                    <tr>
                      <td class="head1">{today_images}</td>
                    </tr>                   
                  </table>
                  {endif today_images}

Finish.
« Last Edit: January 14, 2008, 02:05:49 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 MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: [MOD] - Today upload image - gallery index page
« Reply #1 on: March 29, 2010, 10:29:13 AM »
Great one MOD! Thanks..

Can i show 2 images, not depend on ACP settings,
then paging???

Now it show me 2 images, but it not show paging stat..

Code: [Select]
LIMIT 2 ";
What i need to add to this line??
« Last Edit: March 29, 2010, 06:36:57 PM by MrAndrew »