10 matching records condensed down to 1

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 17, 2009   (RSS)

Hi guys,

I have a housing site where the user is presented with 10 house types. Currently, when the user selects a house e.g. "The Tribeca", they are then presented with all the room images from that particular house. (In the backend we have a 'house' section, and then an 'images' section that pulls the related house from the 'house' section via a list).

Now, the client has introduced a subdivision of the houses where "The Tribeca" is now available in a Coastal, Plantation or Caesar. To keep it simple, I have added a static list field to houses called "house_types" with these 3 options in it. My question is this:

Using search engine urls, is it possible to present the houses list on the
first page, present the house_types list (from the images table) on the subsequent pages, then present the images that match that house_type? Currently, if I do this, the second page will show all tribeca records - tribeca coastal 10 times, tribeca plantation 10 times, etc. Is there any way to condense those 10 repetitions down to 1?

Re: [benedict] 10 matching records condensed down to 1

By Chris - September 15, 2009

Hi benedict,

I'm confused about what you're trying to accomplish.

You mentioned that you've added a static list field to houses called "house_types", but later you say that you want to present the house_types list (from the images table). Is the houses_types field in the houses table, images table, or both?

If you could elaborate on exactly what you want displayed on all three pages (preferably with examples) that would be great. :)
All the best,
Chris

Re: [benedict] 10 matching records condensed down to 1

By Chris - September 17, 2009

Hi benedict,

Ahh, yes. I see the problem.

I think I've figured out what you want to do: filter your records so that the "house_description" field is unique.

Does this code (replacing your STEP 1) do what you need?

<?php
require_once "/home/jmetric/public_html/cmsAdmin/lib/viewer_functions.php";

list($tile_imagesRecords, $tile_imagesMetaData) = getRecords(array(
'tableName' => 'tile_images',
));

function filterUniqueHouseDescriptions($record) {
static $seenDescription = array();
if ( @$seenDescription[$record['house_description']] ) { return false; }
$seenDescription[$record['house_description']] = true;
return true;
}
if (!empty($tile_imagesRecords)) {
$tile_imagesRecords = array_filter($tile_imagesRecords, 'filterUniqueHouseDescriptions');
}

?>


Please let me know if you have any questions.

P.S. Please don't apologize: I love new threads! Less scrolling. :)
All the best,
Chris