Jump to content
NoremPload

Page (SELF) not saved in Page Reference

Recommended Posts

Hi,

I try to use a page reference to make an overview site, but i cannot select (save) the page i use the field on.

-page 1
-- article 1
-- article 2
-page 2
-- article 3
-- article 4

all templates of the pages are selected in selectable templates in field definition.

i am on page 1 and i want to select page 1 as reference. i can select all pages, but if i save, all pages are there (if i select all of them) but not page 1.

anyone can help, or is this the way it should be?

 

Share this post


Link to post
Share on other sites

It turns out PW doesn't allow that.

/**
 * Return PageArray of selectable pages for this input
 * 
 * @param Page $page The Page being edited
 * @return PageArray|null
 * 
 */
public function ___getSelectablePages(Page $page) {
    // ...

    if($children && $children->has($page)) {
        $children->remove($page); // don't allow page being edited to be selected
    }

    return $children; 
}

 

Share this post


Link to post
Share on other sites

Hmm, you can forcibly add it using this hook, though, (not tested)

// site/ready.php

wire()->addHookAfter('InputfieldPage::getSelectablePages', function (HookEvent $e) {
    $e->return->add($e->arguments(0));
});

 

Share this post


Link to post
Share on other sites
On 3/20/2017 at 8:39 PM, Soma said:

Yeah because if you reference a page in it self, it would create a endless reference.

Like @Soma said, I guess this is for preventing circular references when using the field in selectors. It's better if you add it manually in your code

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...