2

I'm trying to figure out the best way to output data and effectively create relationships between a product and it's availability based on the enduser's location.

I'm building a site for consumers of local seasonal vegetables and produce. Basically what would happen is that a user comes to the site and chooses a State via drop down menu, based on their choice, it then populates another form field for cities in that state where local seasonal vegetables and produce are available, the user picks a city and a list of available items gets generated. Then you can click on the item [for this case I'll use broccoli], and it gives you information about that item such as nutritional value, growing season, climate, etc.

Sounds pretty simple, I know. But here's where I'm struggling in figuring out how to create relationships and filter data. For example, on the backend I have listing channel for vegetables that lists all the vegetables available in, say - California, Oregon and Washington for that season. Local organic broccoli is currently available in Seattle WA, Portland OR and Sacramento CA. I need to have broccoli associated with each state, then subsequent city that it's available in. Currently, I have Tagger tags on broccoli for all 6 of those locations, but after further thought, I'm not sure this is a good way to do this because ultimately I'd like to have the farmers markets the broccoli is available in to be dynamically listed on the broccoli page based on the users choices from the drop-downs from the previous page location as well.

I'm not necessarily a newb with EE, but I've not done anything like this before and I'm not sure if there are existing add-ons that would help me do what I'm trying to do, or if I've just got to figure out a way to tie these things together and generate the proper output. I'm a frontend developer trying to figure out how to create relationships with data - not really in my wheelhouse...

If anyone has suggestions, thoughts, advice in how I can properly and effectively create these relationships to output them correctly and have subsidiary data associated with a location [such as markets] tied to the process…it would be immensely appreciated!

Thanks for taking a look at my problem!

1 Answer 1

2

If you have a channel for veg, and a channel as a holder for states and cities and a channel for markets, you could set it up from the veg selected (broccoli) and within that entry in the admin panel, you have two playa Playa fields that reference states, cities, and markets channels respectively.

The only reason I would use playa is to make it so multiple states/markets could be selected. There is probably another way of doing that, like having the states be a category list, but I find playa is nice to use.

Then I always think back from the final URL you want to look over the details from and work your way back. In this case it might be:

http://domain.com/state/city/

Then you would do a lookup for any vegetable that has both the state and city in its record. Within the record you have a market field that spits out the details of that market.

You could also use something like Low Search in place of the entries tag, to spit back things on a more granular level or to include ifs/ands or fuzzy logic.

From that point, you need to have a search form to get you to that URL. A lot like Low Search has in it too, but it could be a custom form as well.

3
  • Thanks for the advice Aaron. I was definitely thinking Playa would have a roll in a solution. I will try to give this a go and let you know!
    – Tre
    Jan 24, 2013 at 14:54
  • Hi Aaron, I've created separate channels per your suggestion but I've got a question. How do you tie [nest, if you will] the states to the cities within the one channel?
    – Tre
    Feb 3, 2013 at 22:35
  • Add the cities to the states channel through a playa field, then associate the cities per state in the state entry. When you look up a state page, www.yourdomain.com/state. You should be able to pull out all of the city entries per state. If you create a vegetable channel like the above, with markets and states assigned by playa, and then simply adjust the criteria per vegetable. It depe des on how you are managing the info - by state or market or veg.
    – Aaron
    Feb 17, 2013 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.