Link 2 section editors...

5 posts by 3 authors in: Forums > CMS Builder
Last Post: October 26, 2009   (RSS)

Hello-

I have a section editor containing house listings, and another section editor containing real estate brokers...When clicking on a broker's name on my web page, I want to bring up all their listings from the first section editor that belong to the broker...I can do this using mysql, but am wondering if I'm overlooking something already built into CMS Builder that would facilitate doing this...

Thanks for any ideas/suggestions you may have...

Rick

Re: [rcrofoot] Link 2 section editors...

By Chris - October 23, 2009 - edited: October 23, 2009

Hi Rick,

Yes, there's already functionality for this built into CMS Builder.

If your listings table's field is called "broker", for example, you can search for matching records in your listings list page like this:

listingsList.php?broker=123

To generate links like that around your brokers' names, you'll want to use the broker's "num" field:

<a href="listingsList?broker=<?php $record['num'] ?>">

I hope this helps! Please let us know if you have any questions.
All the best,
Chris

Re: [chris] Link 2 section editors...

Hi Chris-

I see what you're saying, but this is more the scenario I had in mind:

A web page displays 20 broker names. When I click on a name, a new page displays all of that broker's info (photo, phone numbers, etc.) and all the homes they have for sale. All of their info is coming from the "Brokers" section editor, but all of their listings are coming from the "Homes" section editor. Obviously, the Homes section editor contains many other listings "owned" by the other 19 brokers.

As I see it, when a name is clicked, I can pass something like listings.php?$record['num'], the record num of the broker. But that broker number only exists in the Brokers editor and not in the Homes editor. Only the broker's name exists in the Homes editor, which was entered when that particular home was entered.

So, the only way I can see doing this based on the above is to match the broker name taken from the Brokers section editor and the broker name taken from the Homes section editor...

I'd rather use the unique record num created for each broker in the broker's section editor, but am at a loss as to relating this to the the homes section editor...

Thanks for any futher insight you can add...Rick

Re: [rcrofoot] Link 2 section editors...

By Dave - October 26, 2009

Hi Rick,

If you know mysql you can pass WHERE queries directly to the getRecords() viewer function like this:
where => "brokerNum = 123",

Do you have the viewer page done yet that shows the selected broker? If so, then try adding another viewer code block to the bottom to list _all_ the homes from the homes section.

Once you have that working, add a where to the home viewer code that uses the broker num in there where. Something like this:
'where' => " brokerNum = '" .mysql_real_escape_string($brokerRecord['num']). "' ",

Another tip, you can always add this line to see what SQL is being generated:
'debugSql' => true,

Hope that makes sense. Let me know how it goes and if you need any more help with that! :)
Dave Edis - Senior Developer
interactivetools.com