Hey guys,
I’m working on a classifieds site for businesses and I’ve run into a small problem.
Businesses that have signed up (stored in weblog called businesses) are related to a specific country (in a weblog called countries). These seem to be related fine since you can add businesses and specify their country (via dropdown) in the admin section without problems.
What I am trying to do outside of the admin section is, when viewing a particular business, be able to list other businesses from the same country.
So basically, I’m hoping to do something like feed the particular country name or id to a query on the countries weblog (maybe {reverse_related_entries} ??) and have all the businesses from that country returned.
It’s probably worth mentioning that it’s not just businesses related to the countries weblog - the actual classified listings are related to the countries weblog too. I only need the businesses returned at the moment.
I can’t seem to work out how to do this while avoiding using custom SQL.
I tried something like using the {country_id} returned from {exp:weblog:entries weblog="business"} and passing it to an embedded query {exp:weblog:entries weblog="business" search:country_id="={embed:country_id}”} but that doesn’t seem to work? I’ve looked in the database and {country_id} is not the unique id of the country in the country weblog… (maybe it’s the id of an entry in a bridging table that maps the relationship between the business and country in question?)
Any help/suggestions would be appreciated.
Cheers.