Jump to content

Recommended Posts

Hi all!

I have a little problem here. I want to sort a list of addresses by streetname and then by number. First, I just had a field "prod_objekt" (address) containing both and then have a foreach loop like this: $pages->get('/produzenten/')->prod_repeater->sort('prod_objekt') as $produzent. Unfortunately, this would not sort by streetnumber if I had the same streetname but multiple numbers.

Now, I thought I could sort by two fields. prod_object (adress) first and then by prod_hausnummer (streetnumber). But I just don't know the code for it. I tried this: $pages->get('/produzenten/')->prod_repeater->sort('prod_objekt.prod_hausnummer') as $produzent, but it wouldn't work.

Any ideas on how to solve this?

Thanks for your help

Roli

Link to comment
Share on other sites

Thanks @Zeka

But I don't know where to put that code to make it work..

<?php
  foreach ($pages->get('/produzenten/')->prod_repeater->sort('prod_objekt') as $produzent) { 
?>
<div><a><?= $produzent->prod_objekt ?> <?= $produzent->prod_hausnummer ?>, <?= $produzent->prod_ort ?></a></div>
<?php
  }
?>

The above will only sort by prod_objekt (streetname)...

Link to comment
Share on other sites

2 hours ago, rolisx said:

Now, I thought I could sort by two fields. prod_object (adress) first and then by prod_hausnummer (streetnumber). But I just don't know the code for it. I tried this: $pages->get('/produzenten/')->prod_repeater->sort('prod_objekt.prod_hausnummer') as $produzent, but it wouldn't work.

Use a comma (and perhaps a white space) between your sort properties.

$pages->get('/produzenten/')->prod_repeater->sort('prod_objekt, prod_hausnummer') as $produzent

 

  • 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

×
×
  • Create New...