|
|
Due to the volume of spam happening on our forums, posting is now restricted to verified members only. If you're not verified, drop us a note with your username.
|
|
Home > FlexCMS Support Forum > User Help > FAQ's: General > Featured Product Block
FlexCMS Support Forum
Featured Product Block Started August 23, 2007 @ 11:48am by otter
|
(This thread is currently Locked) |
otter Administrator
Posts: 177 |
|
|
Featured Product Block | August 23, 2007 @ 11:48am | If you've deleted the Featured Product block and need to replace it, simply follow these instructions and you'll be good to go!
FEATURED PRODUCT BLOCK
In your Control Panel, click on the Menu Blocks link under the Edit Site Content box.
From the Menu blocks page:
1) Create a New Block
2) Block Title: Featured Product
3) Copy and paste the following code into the Custom Block Contents area:
Code
if ($IM['ec'] == 'y') { $query = "select * from `".$Settings['DBPrefix']."ec-Settings`"; $result = mysql_query($query) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { $ecSettings[$row['Name']] = $row['Value']; } $ImageExtension[1] = '.gif'; $ImageExtension[2] = '.jpg'; $ImageExtension[3] = '.png'; $ThumbImageExtension[1] = '-thumb.gif'; $ThumbImageExtension[2] = '-thumb.jpg'; $ThumbImageExtension[3] = '-thumb.png';
function RandomCategoryImageB($CatParent5) { Global $Settings, $ecSettings, $CategoryIDsArray, $ProductIDsWithImagesArray, $RandomImageProductIDsArray;
$CategoryID = $CatParent5; for ($j = 0; $j < count($ProductIDsWithImagesArray[$CategoryID]); $j++) { $query = "select * from `".$Settings['DBPrefix']."ec-Items` where Product=".$ProductIDsWithImagesArray[$CategoryID][$j]." limit 1"; $result = mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result) > 0) { $RandomImageProductIDsArray[] = $ProductIDsWithImagesArray[$CategoryID][$j]; } } for ($i = 0; $i < count($CategoryIDsArray[$CatParent5]); $i++) { $CategoryID = $CategoryIDsArray[$CatParent5][$i]; for ($j = 0; $j < count($ProductIDsWithImagesArray[$CategoryID]); $j++) { $query = "select * from `".$Settings['DBPrefix']."ec-Items` where Product=".$ProductIDsWithImagesArray[$CategoryID][$j]." limit 1"; $result = mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result) > 0) { $RandomImageProductIDsArray[] = $ProductIDsWithImagesArray[$CategoryID][$j]; } } if (count($CategoryIDsArray[$CategoryIDsArray[$CatParent5][$i]]) > 0) { RandomCategoryImageB($CategoryIDsArray[$CatParent5][$i]); } } } $query0 = "select RecordNumber, Parent from `".$Settings['DBPrefix']."ec-Categories`"; $result0 = mysql_query($query0) or die (mysql_error()); while ($row0 = mysql_fetch_array($result0)) { $CategoryIDsArray[$row0['Parent']][] = $row0['RecordNumber']; } $query0 = "select RecordNumber, Category, ImageType from `".$Settings['DBPrefix']."ec-Products` where Active='1'"; $result0 = mysql_query($query0) or die (mysql_error()); while ($row0 = mysql_fetch_array($result0)) { $ProductIDsArray[$row0['Category']][] = $row0['RecordNumber']; if ($row0['ImageType'] > 0) { $ProductIDsWithImagesArray[$row0['Category']][] = $row0['RecordNumber']; } }
$RandomImageProductIDsArray = ''; RandomCategoryImageB(0); $RandomProductImage = $RandomImageProductIDsArray[rand(0,(count($RandomImageProductIDsArray)-1))];
if ($RandomProductImage) {
$query7 = "select * from `".$Settings['DBPrefix']."ec-Products` where RecordNumber=".$RandomProductImage." limit 1"; $result7 = mysql_query($query7) or die (mysql_error()); if (mysql_num_rows($result7) > 0) { $row7 = mysql_fetch_array($result7); $ImageWidth = $row7['ImageWidth']; $ImageHeight = $row7['ImageHeight']; $NewWidth = $ecSettings['ThumbMaxWidth']; $NewHeight = $ecSettings['ThumbMaxHeight']; $WidthRatio = $ImageWidth / $NewWidth; $HeightRatio = $ImageHeight / $NewHeight; if ($WidthRatio >= $HeightRatio) { $NewWidthCalc = number_format($ImageWidth / $WidthRatio, 0); $NewHeightCalc = number_format($ImageHeight / $WidthRatio, 0); } else { $NewWidthCalc = number_format($ImageWidth / $HeightRatio, 0); $NewHeightCalc = number_format($ImageHeight / $HeightRatio, 0); } $ImageTag = '<a href="'.$MainURL.'/store/details/'.$row7['ProductID'].'.html" class="BlockColors"><img src="'.$ImagesURL.'/store/store_'.$row7['RecordNumber'].$ThumbImageExtension[$row7['ImageType']].'" width="'.$NewWidthCalc.'" height="'.$NewHeightCalc.'" alt="" border="0"><br>'.$row7['Name'].'</a>'; } }
print $ImageTag;
} |
|
4) Check the box: Process PHP Code? located under theCustom Block Contents area.
5) Save your block.
GENERAL NOTE: The Featured Products block only appears when you have products in your store. If you are not using the store module on your site, the block will never display. We recommend not deleting this block unless you are sure you will never use the store module.
Please note, should you decide to use the store module and choose not to use the Featured Product block, rather than delete it (and this is true of all menu blocks in FlexCMS) simply edit the block and where it says:
Block Enabled?:
Select from the drop down: No (Hidden)
After you save the block, it will no longer display EVEN if you have products in your store.
By choosing the Hidden block route, you'll still have any block available with just the click of your mouse again for future use.
ONLINE TRAINING CLASSES FOR FLEXCMS IN MAY: FlexCMS Basics (101), Sat., May, 15, 2010 & FlexCMS Blocks (Mon., May 10, 2010). |
|
|
|
|
|
|
|
| (This thread is currently Locked) |
|
|
| MEMBERS
|
|
|