Search the Community
Showing results for tags 'position in array'.
Found 1 result
Hi Guys! I have a bit of a puzzle for you. I have been mapping this one out in my brain and on paper all week. I haven't come up with the right solution yet. Here is the project. I am working on a directory site similar to http://demo.processwire.com/ but for another subject. Let's say I am building the skyscraper site but let's say I am doing this for restaurants in cities. I am building a parent page called cities and then a parent page called restaurants. Goal is to display the restaurants according to popularity. Therefore, if I am storing the pages under their appropriate parent. Restaurants are under restaurants and cities are under cities. Visual Page Tree: Cities New York Chicago New Orleans Restaurants Big Toms Burgers McDonalds Dominos Now a restaurant may have 10 locations therefore, I am using a foreach loop inside of the city page to call all restaurants that pertain to this city and sorting by popularity. 🙂 Here is the kicker, how the heck do I document the position the restaurant appears in under the city? Do I save a value in the database? I know I can use a counter to count the loops and assign a value then save that value to the database to the pertaining Restaurant but this relies on page loads and imagine 1000 restaurants all updating at the same time on the database on page load. WOW! No go. How the heck do I save this value without ever having to load a page? ALL IDEAS WELCOME PLEASE! 🙂