Jump to content

[Solved] Load a single repeater item by specifying parent page


da²
 Share

Recommended Posts

Hi,

I think of refactoring several pages into a repeater, but I need to be able to load a single repeater item by specifying the parent page... and I'm struggling.

Here the actual code:

$pages->find("template=repeater_leaderboardCategories, carsOrCarClasses=5941, include=all");

The result:

ProcessWire\PageArray Object
(
    [count] => 2
    [items] => Array
        (
            [LeaderboardCategoriesRepeaterPage:0] => Array
                (
                    [id] => 6065
                    [name] => 1722945441-3239-1
                    [parent] => /cockpit/repeaters/for-field-277/for-page-6057/
                    [template] => repeater_leaderboardCategories
                    [title] => Array
                        (
                            [data] => cat2
                            [data5865] => 
                        )

                )

            [LeaderboardCategoriesRepeaterPage:1] => Array
                (
                    [id] => 6070
                    [name] => 1722946036-4849-1
                    [parent] => /cockpit/repeaters/for-field-277/for-page-6066/
                    [template] => repeater_leaderboardCategories
                    [title] => Array
                        (
                            [data] => champ 2 2
                            [data5865] => 
                        )

                )

        )

    [selectors] => template=repeater_leaderboardCategories, carsOrCarClasses=5941, include=all
)

I get two repeater items, but coming from 2 different pages. So I want to specify the parent page of the repeater (id=6057), but none of my tests have worked.

I've tried a lot of things like this:

$pages->find("template=repeater_leaderboardCategories, carsOrCarClasses=5941, include=all, parent.getForPage=6057");

I also tried to search from the parent page directly:

$page = $pages->get(6057);
$page->leaderboardCategories('carsOrCarClasses=5941');

This works with a ProFields Table, but the repeater loads all items.

Any suggestion?

Edited by da²
Link to comment
Share on other sites

Sorry, I told you I was just guessing ? It should work using the updated code above. Apparently "owner" needs to be prefixed by the name of the repeater field. This time I have tested it.

  • Like 1
Link to comment
Share on other sites

Posted (edited)

Yes this is working, I don't really understand how because the field leaderboardCategories is not used in the rest of the selector... but that works. ?

Edited by da²
Link to comment
Share on other sites

  • da² changed the title to [Solved] Load a single repeater item by specifying parent page

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