Jump to content

sorting repeater fields


pppws
 Share

Recommended Posts

hey there,

 

i have the following structure for a repeater field:

moments, 10x per page (unfortunatly a lot of pages, roughly 400)

-- yearofmoment

-- monthofmoment

-- textofmoment

 

i'm trying to find all repeater fields of certain year and sort them by month. e.g. get all repeater fields of year 1969, first repeater to be displayed: repeaters with monthofmoment = january.

i already got this:

 

<?php $langname = "es"; //temp: only get spanish profiles?>
<?php $persons = $pages->find("template=persons, lang=$langname, moments.yearofmoment=1969") ?>

<?php foreach ($persons as $p): ?>
    <?php foreach ($p->moments as $moments): ?>
        <?php if ($moments->yearofmoment == 1969): ?>
            <ul>
                <li><?= $p->givenname ?>,<?= $moments->month ?> <?= $moments->yearofmoment ?></li>
            </ul>
        <?php endif; ?>
    <?php endforeach; ?>
<?php endforeach; ?>

but somehow i can't figure out how to sort the repeater fields by month. the code above gives me this result: (julio should be on top, luis the last )

Screenshot%202017-11-29%2018.24.27.png?d

 

Link to comment
Share on other sites

no, i want all of the repeaters sorted by month. not only their parent pages.

the screenshot shows all pages wich include a repeater field with the year 1969. the names are the names of the pages. the second number is the month (1 = january, 4 = april and so on) but i don't need the pages to be sorted, but the repeater fields. so the list should be:

julio, 1

selva, 4

gloria, 5

gloria, 5

gloria, 6

miguel, 6

sandra, 7

catalina, 8

luis, 10

hilda, 11

 

 

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...