10 matching records condensed down to 1

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

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: [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