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

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

Hi Dave-

Between Chris' last email and a little experimentation, I got it worked out...

What a great application!

Thanks, Rick