Forum

Thread tagged as: Question, Problem

Displaying regions by name

Hello,

On an old Perch website I have a page on which I have multiple regions. Each region is a city and in each region I have a list of hospitals. Now I would like to display all the hospitals from all the regions in one list, sorted by name on alphabet.

This was the code that I used to display all the hospitals:

                                                perch_content('Delft/Pijnacker/Nootdorp', array (
                                                'sort' => 'naam',
                                                'sort-order' => 'ASC',
                                                )); 
                                                perch_content('Den Haag', array (
                                                'sort' => 'naam',
                                                'sort-order' => 'ASC',
                                                )); 
                                                perch_content('Leidschendam-Voorburg', array (
                                                'sort' => 'naam',
                                                'sort-order' => 'ASC',
                                                )); 
                                                perch_content('Rijswijk', array (
                                                'sort' => 'naam',
                                                'sort-order' => 'ASC',
                                                )); 
Mike Hendriks

Mike Hendriks 0 points

  • 2 years ago
Duncan Revell

Duncan Revell 78 points
Registered Developer

Check out the docs for perch_content_custom - right at the bottom - https://docs.grabaperch.com/functions/content/perch-content-custom/

You can call an array of region names - I've not done this for a while and I can't remember if they are all sorted as one big list or not. Give it a go and see...

I've not done this for a while and I can't remember if they are all sorted as one big list or not...

Yes, it will contain a single array based on the filtering... it will iterate through each region with the specified filtering options and build a single array of results.

perch_content_custom(['News', 'Updates'], [...]);

Of course, this can lead to data of different ‘shapes’ being processed as one collection, so you’ll need to make sure your template or code can deal with that.

Thank you both, will look into it, looks to be right. :)