4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started 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?
-
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:
{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
-
nothing changed? :(
-
i have test it on a another site, it works.
-
i think a change must be done in details.html? maybe i dont have ''random images'' part in details.html?
-
yes the mod works currently only in the categories.html.
-
i need which works in details.html
here is my details.html:
<!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>
</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 />
<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 />
<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> </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.
-
where is the problem, do the same steps in the details.php as in categories.php.
-
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.
-
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
-
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.
-
*lol* one more time:
http://www.4homepages.de/forum/index.php?topic=30549.msg160966#msg160966
-
dude, problems got bigger, now random iamges names, and after clicked names is messing. :)
-
http://www.4homepages.de/forum/index.php?topic=30549.msg160966#msg160966
my god, I hope it works now. :mrgreen:
-
dude it's working perfect right now! i guess! :P thanks a lot!
-
this is vertical and works great, now i just need horizontal version of this. :) thanks in advance.
-
remove the last two "<br>" from the " more_random_image.html".
-
if possible how to Display random from same category if no find similar image?
thank you