4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: uploadeur on February 28, 2012, 02:42:32 AM

Title: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: uploadeur on February 28, 2012, 02:42:32 AM
i need a trick(at left sidebar) which shows 5 or 10 random images from current category.

any ideas?
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: Rembrandt on February 28, 2012, 06:56:47 AM
Hi!

1.)  search in details.php:

//-----------------------------------------------------
//--- Clickstream -------------------------------------

insert above:

//#################### Random Images Start ########################
  $num_random_images = 5; // how many 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, 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 NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").") AND i.cat_id = $cat_id AND i.image_id not in($image_id)
          ORDER BY RAND()
          LIMIT $num_random_images ";
  $result = $site_db->query($sql);
  $num_rows = $site_db->get_numrows($result);

  if(!$num_rows){
    $random_images = $site_template->parse_template("random_image");
  }
  else{
    $random_images ="";
    while ($image_row = $site_db->fetch_array($result)){
    $site_template->register_vars(array(
      "rand_thumbnail" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode,1),
      "rand_image_name" => format_text($image_row['image_name'], 2),
      "rand_user_name" => $image_row['user_name'],
      "lang_comments" => $lang['comments'],
      "rand_image_comments" => ($image_row['image_allow_comments'] == 1) ? $image_row['image_comments'] : "",
    ));
    
      $random_images .= $site_template->parse_template("more_random_image");
    } // end while
  } // end else
  $site_template->register_vars("random_cat_image", $random_images);
  unset($random_images);
//#################### Random Images END ########################


2.) create a new flie call it "more_random_image.html" and store it in your template folder:
Code: [Select]
{rand_thumbnail}<br>{rand_image_name}{if image_is_new} <sup class="new">{lang_new}</sup>{endif image_is_new}<br>
{if allow_comments}{lang_comments} {rand_image_comments}{endif allow_comments}<br>{rand_user_name}<br><br>

3.) now you can, where ever you want, write in details.html "{random_cat_image}"


mfg Andi
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: uploadeur on February 28, 2012, 12:19:39 PM
nothing changed? :(
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: Rembrandt on February 28, 2012, 01:31:23 PM
i have test it on a another site, it works.
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: uploadeur on February 28, 2012, 01:33:23 PM
i think a change must be done in details.html? maybe i dont have ''random images'' part in details.html?
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: Rembrandt on February 28, 2012, 05:30:05 PM
yes the mod works currently only in the categories.html.
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: uploadeur on February 28, 2012, 05:54:36 PM
i need which works in details.html

here is my details.html:



Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="tr" lang="tr">

      

<head>

<title>{image_name}</title>

<meta http-equiv="content-type" content="text/html; charset={charset}">

<meta name="robots" content="noodp">







<link rel="icon" href="favicon.ico" type="image/x-icon" />

<link rel="stylesheet" href="{template_url}/style.css" />






{if has_rss}

<link rel="alternate" type="application/rss+xml" title="{rss_title}" href="{rss_url}" />




{endif has_rss}







</head>

<body bgcolor="#FFFFFF" text="#0F5475" link="#0F5475" vlink="#0F5475" alink="#0F5475">



<table width="640" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>

          <td width="100%"><a href="http://www.resimupload.org"><img src="{template_url}/images/header_logo.jpg" width="840" height="140" alt="" border="0" /></a></td>




  </tr>
  <tr>
    <td class="bordercolor">
      <table width="100%" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <td class="tablebgcolor">
            <table width="100%" border="0" cellspacing="1" cellpadding="0">
              <tr>
                <td class="navbar" height="23">
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">






                    <tr>
                      <td><img src="{template_url}/images/spacer.gif" width="4" height="4" alt="" />{clickstream}</td>
                      <td align="right">
<a href="{url_top_images}"><b>{lang_top_images}</b></a>&nbsp;








 </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>










            <table width="638" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="150" valign="top" class="row2">
                  <table width="150" border="0" cellspacing="0" cellpadding="0">
                    
        







                    
                  </table>
                  {if random_cat_image}
                  <table width="150" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head2" height="20"> <img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_random_image}</td>
                    </tr>
                    <tr>
                      <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>
                    <tr>
                      <td align="center" class="row1"> <br />
                        {random_cat_image} <br />













                        <br />
                      </td>
                    </tr>
                    <tr>
                      <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>
                  </table>
                  {endif random_cat_image} </td>











                <td width="1" class="bordercolor" valign="top"><img src="{template_url}/images/spacer.gif" width="1" height="1" alt="" /></td>
                <td width="18" valign="top"><img src="{template_url}/images/spacer.gif" width="18" height="18" alt="" /></td>
                <td width="100%" valign="top"><br />






<br>

<table width="100%" border="0" cellspacing="0" cellpadding="1">
                    <tr>
                      <td class="bordercolor">
                        <table width="100%" border="0" cellspacing="0" cellpadding="3">
                          <tr valign="top">
                            <td class="row2"> {if prev_image_name}{lang_prev_image}<br />&nbsp;&nbsp;
                              <b><a href="{prev_image_url}"><img src="http://www.resimupload.org/templates/onceki-resim.png"
 alt="" width="144" height="38" /></a></b>
                              <!-- <br><br><a href="{prev_image_url}"><img src="{prev_thumb_file}" border="1"></a> -->
                              {endif prev_image_name} </td>
 <td align="right" class="row2">  {if next_image_name}{lang_next_image}<br>
                              <b><a href="{next_image_url}"><img src="http://www.resimupload.org/templates/sonraki-resim.png" alt="" width="143" height="38" /></a></b>
                              <!-- <br><br><a href="{next_image_url}"><img src="{next_thumb_file}" border="1"></a> -->
                              {endif next_image_name}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>

<br>




                  <b class="title">{image_name}</b>{if image_is_new} <sup class="new">{lang_new}</sup>{endif
                  image_is_new}
                  <hr size="1" />
                  {if msg}<b>{msg}<br />
                  <br />
                  </b>{endif msg}
                  <div align="center">
 {image}


<p>






<table width="100%" border="0" cellspacing="0" cellpadding="1">
                    <tr>
                      <td class="bordercolor">
                        <table width="100%" border="0" cellspacing="0" cellpadding="3">
                          <tr valign="top">
                            <td class="row2"> {if prev_image_name}{lang_prev_image}<br />&nbsp;&nbsp;
                              <b><a href="{prev_image_url}"><img src="http://www.resimupload.org/templates/onceki-resim.png"
 alt="" width="144" height="38" /></a></b>
                              <!-- <br><br><a href="{prev_image_url}"><img src="{prev_thumb_file}" border="1"></a> -->
                              {endif prev_image_name} </td>
 <td align="right" class="row2">  {if next_image_name}{lang_next_image}<br>
                              <b><a href="{next_image_url}"><img src="http://www.resimupload.org/templates/sonraki-resim.png" alt="" width="143" height="38" /></a></b>
                              <!-- <br><br><a href="{next_image_url}"><img src="{next_thumb_file}" border="1"></a> -->
                              {endif next_image_name}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>

















</div>
                  
                  <table width="100%" border="0" cellspacing="0" cellpadding="1">
                    <tr>
                      <td class="bordercolor">
                        <table width="100%" border="0" cellpadding="3" cellspacing="0">
                          <tr>
                            <td class="head1" valign="top" colspan="2">{image_name}</td>
                          </tr>
                          <tr>
                            <td valign="top" class="row1" width="33%"><b>{lang_description}</b></td>
                          
                         </tr>
                          <tr>
                            <td valign="top" class="row1"><b>{lang_date}</b></td>
                            <td valign="top" class="row1">{image_date}</td>
                          </tr>
                          <tr>
                            <td valign="top" class="row2"><b>{lang_hits}</b></td>
                            <td valign="top" class="row2">{image_hits}</td>
                          </tr>
                          
                          <tr>
                            <td valign="top" class="row2"><b>{lang_rating}</b></td>
                            <td valign="top" class="row2">{image_rating} ({image_votes}
                              {lang_votes})</td>
                          </tr>
                          <tr>
                            <td valign="top" class="row1"><b>{lang_file_size}</b></td>
                            <td valign="top" class="row1">{image_file_size}</td>
                          </tr>
                        
                        </table>
                      </td>
                    </tr>
                  </table>
                  
{if rate_form}
                  <br />
<div align="center">{rate_form}</div>
                  {endif rate_form}

                  <br />
                  




                  <p>&nbsp;</p>
                </td>
                <td width="20" valign="top"><img src="{template_url}/images/spacer.gif" width="19" height="19" alt="" /></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tablebottom">
        










      </table>
    </td>
  </tr>
</table>
{footer}


you can see there is a random image trick, i need like that who shows 5-10 random images from SAME CURRENT CATEGORY.
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: Rembrandt on February 28, 2012, 07:37:55 PM
where is the problem, do the same steps in the details.php as in categories.php.
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: uploadeur on February 28, 2012, 07:54:08 PM
oh in details.php works like a charm! thanks, but one think, one of the random image is same as current image, i want to make ALL random. how can i?

and one more thing: veritical random images at the sidebar OK but, how about horizontal random images for the bottom of the current image?

and one serious problem occurs: when i click a thumbnail, a different image shows up, not the one that thumbnail's.
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: Rembrandt on February 29, 2012, 08:11:37 AM
I have made a new code above
http://www.4homepages.de/forum/index.php?topic=30549.msg160966#msg160966

now i hope it works.  :wink:

mfg Andi
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: uploadeur on February 29, 2012, 11:13:49 AM
works great! thanks!

i found one problem: random images shown always by current iamge name, but there are not sometimes, so i need to make self names' of random images.
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: Rembrandt on February 29, 2012, 06:16:21 PM
*lol* one more time:
http://www.4homepages.de/forum/index.php?topic=30549.msg160966#msg160966

Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: uploadeur on February 29, 2012, 06:43:21 PM
dude, problems got bigger, now random iamges names, and after clicked names is messing. :)
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: Rembrandt on February 29, 2012, 10:06:01 PM
http://www.4homepages.de/forum/index.php?topic=30549.msg160966#msg160966

my god, I hope it works now.  :mrgreen:
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: uploadeur on February 29, 2012, 10:14:10 PM
dude it's working perfect right now! i guess! :P thanks a lot!
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: uploadeur on March 27, 2012, 10:44:09 AM
this is vertical and works great, now i just need horizontal version of this. :) thanks in advance.
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: Rembrandt on March 27, 2012, 01:07:18 PM
remove the last two "<br>" from the " more_random_image.html".
Title: Re: [Mod] More random images, from current (same) Category, show on the Detail page
Post by: wallward on January 19, 2014, 09:50:24 AM
if possible how to Display random from same category if no find similar image?
thank you