Jump to content

Problem with Page Select


Soma
 Share

Recommended Posts

I'm using latest PW 2.2

I experience a problem with the page field. When I define a page as the parent like /produkte/, and as select type I chose PageListSelect. No other options.

Then on page where this field is, I go and select a page from the tree, after saving page it isn't there anymore. I figured that it happens only when I select a page further down. If I select a page from the direct child of the parent it works. A bug?

/produkte/

--- /page1/ (works)

--- /page2/ (works)

------ /page2a/ (doesn't work)

--- /page3/

Link to comment
Share on other sites

Now trying other options. WIth the new "custom selector" option.

I enter "parent=/produkte/, template=product" there and no pages show up in the ASM select.

When I change it to "template=product" it works. The parent page /produkte/ is hidden. But even with "include=all" it doesn't work. Guess it must be another problem.

Link to comment
Share on other sites

Then on page where this field is, I go and select a page from the tree, after saving page it isn't there anymore. I figured that it happens only when I select a page further down. If I select a page from the direct child of the parent it works. A bug?

I couldn't duplicate this until I tried with changing it to a single-page field rather than multi-page field. That did it, I could duplicate it. I looked closer and see we have an optimization that enforces the parent at load time, but only for single-page mode. Usually this optimization would be good, as it gives a slight performance edge. But obviously it's not good with PageListSelect, so I removed it. Thanks for finding this. I've committed the update to the 2.2 source.

I enter "parent=/produkte/, template=product" there and no pages show up in the ASM select.

When I change it to "template=product" it works. The parent page /produkte/ is hidden. But even with "include=all" it doesn't work. Guess it must be another problem.

Is this paired with one of the PageListSelect inputfields? You mentioned asmSelect, but since PageListSelectMultiple also uses an asmSelect style sort list, I'm not sure. You probably saw the note with 'selector' and 'template' where it says "This is not compatible with PageListSelect inputfields". However, it should be compatible with a regular asmSelect Inputfield. But you might need to use parent=123 (page ID) rather than parent=/produckte/, though not for long (already a fix for that but still tweaking it).

Link to comment
Share on other sites

But you might need to use parent=123 (page ID) rather than parent=/produckte/, though not for long (already a fix for that but still tweaking it).

Nevermind about this, I was wrong as that limitation never made it into the code at GitHub (was already fixed before I pushed it to GitHub). I tried this as my selector with a multi-page field using asmSelect:

parent=/building-types/, template=airports|aquariums

It worked for me, showing the selectable pages I wanted it to. Is there anything else I need to do to duplicate?

Link to comment
Share on other sites

Thanks for the fix.

Yes as i mentioned im using asm select. Nothing special else. Does it work for you? It even shows an example there... using same selector, but cant get it to work. Im also have it set to single page.

Link to comment
Share on other sites

@apeisa, not much except that I like it fancy ;) seriously I like the bar item it adds with a trash icon, opposed to having a simple dropdown. I always thought it is more clear to the unexperienced user, but it may be more personal preference.

@Ryan, I still can't get it to work. I have same setting as you, I checked various options, it doesn't matter if single or multiple or what select input type.. strange. Whenever I remove the parent in the custom selector it works. ?

Link to comment
Share on other sites

Yes as i mentioned im using asm select. Nothing special else. Does it work for you? It even shows an example there... using same selector, but cant get it to work. Im also have it set to single page.

It does work for me. Are you sure you don't have one of the other fields populated, like parent or template? Let me know if you can think of anything else I might try to duplicate here.

Also, regarding Antti's question -- are you using an asmSelect with a 1-page reference? asmSelect is only meant for multi-page references.

Link to comment
Share on other sites

I think I found it. When I remove the "template=product" it works. but it only lists the direct childs of the parent. So kinda same issue as with the other problem before. Not big deal, as I can just use the "template=", but I would expect it to look through all pages below the parent not just direct childrens. If that's really the problem.

Edit: I would work with the php custom code "return $pages->get("/produkte/")->find("template=product");" that's what I kinda thought it would do with the custom selector string option when using parent. But guess I'm wrong.

Edit: I also thought using a parent would be more performant when going with a parent instead to search through all pages. It's also dependent on my setup why I ran into it. Produkte is like

/produkte/

---/category1/

------/product1/

------/product2/

---/category2/

------/product3/

---/category3/

------/product4/

------/product5/

...

Link to comment
Share on other sites

No matter where you use a selector like "parent=/path/" in the API, it's always going to refer just to direct children of that parent. The selector used in this field setting exhibits the same behavior as the rest of the API. I think what you might be looking for instead is the "has_parent" selector option, which is a way to refer to a page having a parent anywhere in it's ancestor tree. You won't see "has_parent" used in the API very much (or ever?) because you'd typically do this instead:

$pages->get('/products/')->find('template=product'); 

But behind the scenes, that actually translates to this:

$pages->find('has_parent=123, template=product'); 

123 is the ID of /products/. The "has_parent" has to be used with an ID rather than a path, though I'll probably change that, now that there's an external use for it.

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