theoretic Posted February 9, 2021 Share Posted February 9, 2021 Hi there! And thanks for Processwire! I have an interesting task which i cannot fulfill as i want. Maybe someone could help me please? Let's imagine a simple page structure of this kind: Category 1 + Item 1.1 + Item 1.2 Category 2 + Item 2.1 + Item 2.2 My task is to attach some items to more than one category, at least to show some items on different frontend category pages. With PW, it's a piece of cake. I've just created a field called Items (of type Page Reference) and attrached it to Category template. Since i have lots of items inside each category i preferred to use Page Autocomplete input for my Items field. The pages available for autocomplete are restricted by a very simple selector: template=item It works like a charm. But later i decided to make this autocomplete even smarter and to exclude current category children items from it. I tried to update my selector this way... template=item,parent!=(page) ...and oops, this broke my selector. My autocomplete founds nothing. Sorry, i had to replace the square braces by () because of this forum limitations, i swear i'm using square brackets in real-life selector! What am i doing wrong? And is there any way to include current page info in autocomplete-related selectors? Thanks in advance! Link to comment Share on other sites More sharing options...
kongondo Posted February 9, 2021 Share Posted February 9, 2021 Hmm, for some reason, I cannot see your post @theoretic! I am just seeing navigation buttons <next page> etc! I can see the post when I edit it (as a moderator - I didn't actually edit it). I am not sure whether it is my computer or my eyesight, or age! Anyone else seeing this? @Pete?? Link to comment Share on other sites More sharing options...
theoretic Posted February 9, 2021 Author Share Posted February 9, 2021 Sorry guys. It appears i've run into an issue with the forum editor. I tried to edit my post around 10 times, it's still not visible. So i'll try to post it as plain text. Hi there! And thanks for Processwire! I have an interesting task which i cannot fulfill as i want. Maybe someone could help me please? Let's imagine a simple page structure of this kind: Category 1 + Item 1.1 + Item 1.2 Category 2 + Item 2.1 + Item 2.2 My task is to attach some items to more than one category, at least to show some items on different frontend category pages. With PW, it's a piece of cake. I've just created a field called Items (of type Page Reference) and attrached it to Category template. Since i have lots of items inside each category i preferred to use Page Autocomplete input for my Items field. The pages available for autocomplete are restricted by a very simple selector: template=item It works like a charm. But later i decided to make this autocomplete even smarter and to exclude current category children items from it. I tried to update my selector this way... template=item,parent!=(page) ...and oops, this broke my selector. My autocomplete founds nothing. Sorry, i had to replace the square braces by () because of forum limitations, i swear i'm using square brackets in real-life selector! What am i doing wrong? And is there any way to include current page info in autocomplete-related selectors? Thanks in advance! Link to comment Share on other sites More sharing options...
adrian Posted February 9, 2021 Share Posted February 9, 2021 1 hour ago, theoretic said: And is there any way to include current page info in autocomplete-related selectors? Just make use of the $page variable like: "template=item, parent!=$page" Note the double quotes, or if you prefer: 'template=item, parent!='.$page 1 Link to comment Share on other sites More sharing options...
Robin S Posted February 10, 2021 Share Posted February 10, 2021 In the "Selector string" setting for "Selectable pages" you can use "page" to refer to the current page, but only if you also specify a subfield using dot syntax. In your case you would use page.id to exclude children of a parent: template=item, parent!=page.id Unfortunately I don't think this is documented anywhere. 1 1 Link to comment Share on other sites More sharing options...
ErikMH Posted April 3, 2022 Share Posted April 3, 2022 You just saved my bacon, @Robin S — thanks for this! For those searching, this is the secret sauce for presenting a subset of entries to select from, based on a previous selection. In my case: parent=page.refSection where refSection is a grosser-level selection in a hierarchy. I believe this also answers this question: 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now