Showing featured products in separate section

10 posts by 2 authors in: Forums > CMS Builder
Last Post: August 23, 2012   (RSS)

By coliva - August 15, 2012

Hi,

We manage a gourmet food website where the products are organized by Product Categories, Brands and Products, in that hierarchical order. www.finica.com.

The site has a What's New section where we display new/featured products. However these are duplicate items. Because we cannot assign more than 1 brand to an item, these items were assigned the brand "What's New". I know that to do this correctly we should set the products up using a 'featured' checkbox in the product page, but I'm not entirely clear on how to do this (even after having read some posts on the matter). Our PHP knowledge is limited.

How do we set this up to correctly display the products without having to duplicate them?

One thing to note - on the What's New section, we only want to list the brands that include a featured product, we do not want to list the products. So we would have to check the product's featured value, but display its corresponding brand. Then when the brand name is clicked, this will load the existing brand page of the site. We would like to highlight that a product is 'new' by adding the text "New" after the product name, triggered by a check of the 'featured' field value.

Any help that you could lend on this is very much appreciated!

Thank you,
Claudia

Re: [coliva] Showing featured products in separate section

By Jason - August 16, 2012

Hi Claudia,

No problem. Could you please attach the .php file that is outputting your menu list. This will give us a better idea of how you're structuring things, which should help us come up with a solution.

thanks,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Showing featured products in separate section

By coliva - August 17, 2012

Hi Jason,

Sure thing. I'm attaching a copy a few page types for your reference. The nav menu on the left is hardcoded, you'll be able to see the code in any of the attached php files (is this what you're referring to by menu list, or are you referring to the links regenerated on the What's New page? - the template used there is brandsDetail.php).

We've combined multiple list pages into one to create the category pages (product_categoriesDetail.php). These list the brands with the individual product links for each.

Please let me know if you need anything else.

Thanks,
Claudia

Re: [coliva] Showing featured products in separate section

By Jason - August 17, 2012

Hi,

Okay, I think I've found a pretty easy way to go about this.

First, you'll need to go into your products section and add a "featured" checkbox. You'll then check off this value for all products that you want to display in "What's New", regardless of what brand they belong to.

Next, we'll change the menu link to the "What's New" section like this:

<p class="menu_head"><a href="#section2">What's New</a></p>
<div class="menu_body">
<a href="brandsDetail.php?featured=1">View New Products</a>
</div>


Next, we'll re-arrange the code on brandDetails.php some:

// load records
list($brandsRecords, $brandsMetaData) = getRecords(array(
'tableName' => 'brands',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));

$brandsRecord = @$brandsRecords[0]; // get first record

// show error message if no matching record is found
if (!$brandsRecord) { dieWith404("Record not found!"); }


if (@$_REQUEST['featured'] == 1) {
list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'where' => "featured = '1'",
'allowSearch' => false,
));
}
else {
list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'where' => "brand = '".intval($brandsRecord['num'])."'",
'allowSearch' => false,
));
}


This will either return featured products, or products associated with the selected brand.

Finally, we remove the check from the foreach loop:

<?php foreach ($productsRecords as $record): ?>
<?php if ($record['brand'] == (int)$brandsRecord['num']): ?>
<tr>
<td width="100" style="padding-bottom:15px">
<div class="border">
<?php foreach ($record['thumbnail'] as $upload): ?>
<a href="<?php echo $record['_link'].$record['section_number'] ?>">
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
</a>
<?php endforeach ?>
</div>

</td>
<td align="left" style="padding-left:10px" valign="top"><span class="heading4"><a href="<?php echo $record['_link'].$record['section_number'] ?>"><?php echo $record['title'] ?></a></span><BR />
<?php
$html = preg_replace("|</p>\s*$|i", "", $record['content'] );
$html = cutText($html, 170);
$html = $html . "...</p>";
echo $html;
?>
</td>
</tr>
<?php endif ?>

<?php endforeach ?>


give that a try and let me know if you run into any issues.

Thanks,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Showing featured products in separate section

By coliva - August 21, 2012

Hi Jason,

Thanks for help on this! I tried the changes as per below and ran into two issues.

1. On the What's New page, we actually don't want to list the individual products. We just want to list the brands that correspond to them as links (similar to how they appear on the Cheeses/View All Products page (but not list the individual products below). Then clicking on the links will take you to the existing Brand page.

The logic for this page is working correctly though. You'll see that we've tagged 2 products are 'featured' and they are displaying.

2. The other brand pages now are not listing any of the products.

We've uploaded these changes on our test site: http://test.finica.com

Let me know if you need me to attach any files. Any input is very much appreciated.

Thanks,
Claudia

Re: [coliva] Showing featured products in separate section

By Jason - August 22, 2012

Hi Claudia,

Let's start with the second problem where brand pages are no longer showing information. Could you please attach your new brandDetails.php page so I can take a look at the changes made?

Thanks,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Showing featured products in separate section

By coliva - August 22, 2012

Let's try this again :)
Attachments:

brandsdetail_001.php 13K

Re: [coliva] Showing featured products in separate section

By Jason - August 23, 2012

Hi,

If I could get you to send in a [url http://www.interactivetools.com/support] 2nd Level Support[/url] Request I can take a closer look at this for you.

Thanks,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Showing featured products in separate section

By coliva - August 23, 2012

Thanks Jason. I submitted the request.