Related Entries

5 posts by 2 authors in: Forums > CMS Builder
Last Post: June 30, 2011   (RSS)

By Kenny - June 28, 2011

Hi all -

I am having a problem getting records from one table to show up with records from another.

Here's the idea...

I have a section called "models". This section was built to show the different models of building available.

Each model can have a multitude of floor plans. I have created another section called "floor plans" and tie the floor plans to the models with a drop down option (get options from a database).

So, if I have a model called Sandy Lake, I can now make as many floor plans as I want for Sandy Lake.



Now, the part I am failing at the moment:

How do I get all of the floor plans for Sandy Lake to show up on the model page for Sandy Lake?


list($modelsRecords, $modelsMetaData) = getRecords(array(
'tableName' => 'models',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$modelsRecord = @$modelsRecords[0]; // get first record


list($floor_plansRecords, $floor_plansMetaData) = getRecords(array(
'tableName' => 'floor_plans',
));


Thanks in advance...

Kenny

Re: [Kenny] Related Entries

By robin - June 29, 2011

Hey Kenny,

You'll need to match the num of the current model to the drop down of the floor plan. I've inserted an example below, you might need to change the name of the drop down - I've assumed it's called "model". This is also assuming you're using num for the drop down list option values.

list($floor_plansRecords, $floor_plansMetaData) = getRecords(array(
'tableName' => 'floor_plans',
'where' => "model='" . $modelsRecord['num'] . "'"
));


Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Related Entries

By Kenny - June 29, 2011

Couldn't get that to show anything

I have attached the file, can you tell me if I have it set up correctly?

model is actually "series" in the drop down list

Re: [robin] Related Entries

By Kenny - June 30, 2011

Thanks - that was the problem. All is well now!

Kenny