Quote:
Originally Posted by maineGuy72
for random items with no photo.....
|
Try to replace the whole function getRandom($catid) in functions.php with this code:
Code:
// Get Random Items
function getRandom($catid)
{
global $db, $vbulletin, $vbphrase, $random_items, $random_items_bit, $catid;
if (empty($catid))
{
$catid = 0;
}
$maximum_random = $vbulletin->options["microclassifieds_random_items"];
$SubIds = array();
$getSub = _getChildId($SubIds, $catid);
$browsecategories = implode($SubIds, ', ');
$sql_random = $db->query_read("SELECT * FROM ".TABLE_PREFIX."microclassifieds_items WHERE categoryid IN ($browsecategories) AND logo<>'' AND active=1 AND sold=0 AND hidden=0 ORDER BY rand() LIMIT $maximum_random");
$total_random = $db->num_rows($sql_random);
if($total_random == 0)
{
$sql_random = $db->query_read("SELECT * FROM ".TABLE_PREFIX."microclassifieds_items WHERE logo<>'' AND active=1 AND sold=0 AND hidden=0 ORDER BY rand() LIMIT $maximum_random");
}
$i = 0;
$html_random = '';
$thumb_path = 'microclassifieds/photos/thumbs/';
while($random = $db->fetch_array($sql_random)) {
if($i%2!='0')
{
$html_random .= '<tr><td height="35"> </td></tr>';
}
if($i >= 2)
{
$html_random .= '</table></li><li><table cellpadding="3" cellspacing="0" border="0" width="100%">';
$i = 0;
}
$i++;
$title = getTitle($random['title']);
$thumb = $thumb_path.$random['logo'];
$price = getFormatPrice($random['price']);
$html_random .= '<tr valign="top"><td width="90" align="left">
<a href="classifieds.php?do=viewitem&itemid='.$random["id"].'">
<img src="'.$thumb.'" border="0" /></a></td>
<td align="left"><h4><a href="classifieds.php?do=viewitem&itemid='.$random["id"].'">'.$title.'</a>
</h4>'.$price.' '.$vbulletin->options["microclassifieds_currency"].'</td></tr>';
}
$templater = vB_Template::create('microclassifieds_random_items');
$templater->register('html_random', $html_random);
$random_items .= $templater->render();
return;
}
This code:
- Shows only Ads with photos
- Shows Ads from subcategories too