Jump to content

Repeater Item with Page Reference Field selecting Repeater Items (including itself)


t0b1
 Share

Recommended Posts

Hello there, and thanks for ProcessWire!

I'm getting to know ProcessWire while doing my first project using it and I really like it so far.
The challenge I'm facing right now is the following:

I have a One-Pager using fullpage.js, realized as a single PW-Page containing a Repeater Field where each Repeater Item is one Section.
Some Sections are supposed to have a little menu at the Top which references/links to different Sections of the Website, so I wanted to use a Checkbox Field "Top Menu" to decide if a Section gets a Menu and a Page Reference Field to choose the different Sections (Repeater Items) it should contain.
I've already accomplished this by pasting the following code into /site/ready.php:

 

$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
    if($event->object->hasField == 'top_menu_entries') {
        $page = $event->arguments('page');
        if($page instanceof RepeaterPage) $page = $page->getForPage();
        $event->return = $page->;
    }
});

 

The only problem that still remains is that when I select the Entry of the Repeater Item itself it doesnt save the selection, meaning after I saved it's unselected again.
On some Sections I do want a Menu-Entry for the Section itself though (which would be styled differently and not link anywhere) for Continuity-Reasons, any ideas on how to achieve that?

Link to comment
Share on other sites

2 minutes ago, t0b1 said:

 


$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
    if($event->object->hasField == 'top_menu_entries') {
        $page = $event->arguments('page');
        if($page instanceof RepeaterPage) $page = $page->getForPage();
        $event->return = $page->;
    }
});

The last line was supposed to be $event->return = $page->fullpage_sections;
fullpage_sections is my Repeater Field

  • Like 1
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...