Author Topic: Showing more RAndom images on other MODS  (Read 4176 times)

0 Members and 1 Guest are viewing this topic.

Offline zakaria666

  • Full Member
  • ***
  • Posts: 211
    • View Profile
Showing more RAndom images on other MODS
« on: September 04, 2010, 03:07:00 PM »
Thank you Vano and remabrant on the last issue i had. It worked.

I just have an issue with putting more random images into other places. For example inside the index.php the below code is the random image part that display the 6 images i want. But on the PM MOD http://www.4homepages.de/forum/index.php?topic=6692.0 and Friend MOD http://www.4homepages.de/forum/index.php?topic=27705.0 or any other MOD for that matter, how do i show more random images. So when i click on inbox link, it shows me my messages but only 1 random image on the side. Now I know Vano and many will say to put this topic under the specific topic that I may have an issue with. Bt then that wil mean writing under every MOD ive ever installed and complaining about the same thing  :lol:. So having this 1 topic will solve the issue for all users who will want to show more random images on the side. The code below i took from index.php and put into pm.php and buddy.php but it didnt work.

I hope I havent done anything wrong. I hope I could recieve assistence on this. Thank u in advance to any help given.


Code: [Select]
//------------------------------------
//------- Random Images --------------
//------------------------------------
$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 IN (".get_auth_cat_sql("auth_viewcat").")
        ORDER BY RAND()
        LIMIT 6";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

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

    show_image($image_row);
    $random_images .= $site_template->parse_template("thumbnail_bit");
    $random_images .= "\n</td>\n";
    $count++;
    if ($count == 1) {
      $random_images .= "</tr>\n";
      $count = 0;
    }
  } // end while

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


$site_template->register_vars("random_images", $random_images);
unset($random_images);

//----- End Random Images---------

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Showing more RAndom images on other MODS
« Reply #1 on: September 04, 2010, 03:32:11 PM »
Did you add {random_images} into main templates of these mods?

P.S.
Saying "doesn't work" is not helpful at all.
Your first three "must do" before you ask a question:
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)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline zakaria666

  • Full Member
  • ***
  • Posts: 211
    • View Profile
Re: Showing more RAndom images on other MODS
« Reply #2 on: September 04, 2010, 04:10:42 PM »
@VANO.

Im sorry, what i meant by saying that it doesnt work is that nothing happened, I copy pasted the code from index.php then put it inside pm.php and even the buddy.php and just nothing happened it was exactly the same. Just displaying 1 random image.

I even changed {random_image} to {random_images} with the s at the end of image and that didnt work either, infact that random image didnt appear.

I just want to display more random images just like how the index page does. Before i limited it to 6 the index page was just displaying 1 random image until u showed me the code inside index.php and i changed it to 6 and now the index page display 6 image. The same thing i want to happen to pm.php and buddy.php and any other MOD. Is there a sort of trick i could to to display it in every page not just the index.php

Thanks again man.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Showing more RAndom images on other MODS
« Reply #3 on: September 04, 2010, 04:37:25 PM »
try move that code into include/page_header.php
above :above: //-----------------------------------------------------
//--- Random Image ------------------------------------
//-----------------------------------------------------


(make sure you remove it from index.php as well)
Your first three "must do" before you ask a question:
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)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline zakaria666

  • Full Member
  • ***
  • Posts: 211
    • View Profile
Re: Showing more RAndom images on other MODS
« Reply #4 on: September 04, 2010, 05:10:42 PM »
@Vano

You are freakin amazing. It worked. Pure genius man!

Thank you 100x