Jump to content

selector grouped by parents


Frank Vèssia
 Share

Recommended Posts

Hi,
it's possible to get the result of a selector grouped by parents?
My structure is like this

restaurant 1
  - dish
  - dish
 ...
restaurant 2
  - dish
  - dish
  ...

In my search form there is a free text for searching a dish and a location. (location info is inside restaurant)
The result of the search should be the list of restaurants offering that particular dish, with the dishes below.

Right now I first search all restaurants in that location and after that all dishes (if they have) and display the result by restaurant.
This is not the best because I have to search all restaurant I have first.

I tried just to search for the dishes with parent in that location but in this way I can display only the dishes list and I need to display the restaurants list with the dishes below. :)

Link to comment
Share on other sites


$dishes = $pages->find("…, sort=parent, sort=XX");

$parentID = null;

foreach($dishes as $dish) {

if($parentID === null || $dish->parent->id !== $parentID){

$parentID = $dish->parent->id;

// render restaurant headline

}

// render dish list item

}

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...