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: [chris] 10 matching records condensed down to 1

Hi Chris,

Sorry to be so obtuse. If you go to http://www.metricontilestudio.com.au you will see the houses from the house table. If you then click on a house (e.g.) Santorini, you will see I have called the list of images but I am deliverately only showing their house name and house_description (which are both fields in the tile_images table that you so rightly pointed out). You will see the problem - I only want it to say:

"Santorini 31 Coastal" once (instead of 10 times) and say "Santorini 28 Coastal" only once (instead of 10 times).

I have attached the file for your inspection if needed.

Everything else works fine (P.S. Sorry for opening a new thread on this project, it just seemed the old thread had nothing to do with this).

Cheers,

B
Attachments:

houseselector.php 7K

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