Guest acematti Posted February 5, 2007 Share Posted February 5, 2007 Hi, I am trying to modify my store so that i can have a nice list of featured products so I have changed the randProd.inc to look like the following: $maxProds = 3; if (ereg(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) || ereg(".inc.php",$_SERVER['PHP_SELF'])) { echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>"; exit; } mt_srand ((double) microtime() * 1000000); $seed = mt_rand(1,10000); if(isset($_GET['catId'])){ $whereClause = "WHERE cat_id=".$db->mySQLSafe($_GET['catId']); } else { $whereClause = ""; } $randProd= $db->select("SELECT name, image, productId, description FROM ".$glob['dbprefix']."CubeCart_inventory ".$whereClause." ORDER BY RAND(".$seed.") LIMIT ".$maxProds); if($randProd==TRUE){ for($i=0; $i < count($randProd); $i++){ if(($val = prodAltLang($randProd[$i]['productId'])) == TRUE){ $randProd[$i]['name'] = $val['name']; } $box_content=new XTemplate ("skins/".$config['skinDir']."/styleTemplates/boxes/randomProd.tpl"); $box_content->assign("LANG_RANDOM_PRODUCT",$lang['front']['boxes']['featured_prod']); $box_content->assign("PRODUCT_ID",$randProd[$i]['productId']); $box_content->assign("PRODUCT_NAME",validHTML($randProd[$i]['name'])); $shortDescription = truncate_string($randProd[$i]['description'],300); $box_content->assign("PRODUCT_DESCRIPTION",validHTML($shortDescription)); if(!empty($randProd[$i]['image'])){ $box_content->assign("IMG_SRC","images/uploads/thumbs/thumb_".$randProd[$i]['image']); } else { $box_content->assign("IMG_SRC","skins/".$config['skinDir']."/styleImages/thumb_nophoto.gif"); } /*$box_content->parse("random_prod"); $box_content = $box_content->text("random_prod");*/ $box_content->assign("DATA",$randomProd[$i]); $box_content->parse("random_prod.li"); } } else { $box_content = ""; } function truncate_string($details,$max) { if(strlen($details)>$max) { $details = substr($details,0,$max); $i = strrpos($details," "); $details = substr($details,0,$i); $details = $details." ..... "; } return $details; } ?> I have wanted to make it so that there were 3 extra featured products so i changed the limit to 3. I then went into the boxes folder and altered the randomProd file so that it looked like this: <!-- BEGIN: random_prod --> <!-- BEGIN: li --> <div class="featuredProductHeader">{LANG_RANDOM_PRODUCT} - {DATA.name}</div> <div class="featuredProductContent"> <div class="featureImage"><a href="index.php?act=viewProd&productId={PRODUCT_ID}" title="{PRODUCT_NAME}"><img src="{IMG_SRC}" alt="{PRODUCT_NAME}" border="0" title="{PRODUCT_NAME}" /></a></div> <div class="featureDesc"> {PRODUCT_DESCRIPTION}<br /><a href="index.php?act=viewProd&productId={PRODUCT_ID}" title="{PRODUCT_NAME}">More</a> </div> </div> <!-- END: li --> <!-- END: random_prod --> I basically took bits of the code from the popular products and changed it to my needs. However it is not working. All it displays is the word "Object" with none of the expected divs etc so it is not even getting to loop through the products. Any help on this matter would be great, Thanks in advance Matt Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.