MarcC Posted January 16, 2012 Share Posted January 16, 2012 I have a checkbox I'm using to control whether an article is shown on the front page. The field name is display_options, a page array set to multiple pages API ref, displayed as checkboxes. Its page array parent is /tools/display-options, and there are two children, not-shown-on-front-page and not-shown-in-archive. Right now I just want to make sure that the first one works: Not Shown on Front Page. Here's the working "before" code with no test for the checkbox: $stories = $pages->get('/news/co-op-news')->children("limit=4"); Here's the code with a selector added for the front page display test: $stories = $pages->get('/news/co-op-news')->children("limit=4, display_options!=not-shown-on-front-page"); ...but that shows only the article where I have checked "Not Shown on Front Page" (the opposite of what I want to see). :-/ I also tried this: $stories = $pages->get('/news/co-op-news')->children("limit=4, display_options=not-shown-on-front-page"); ...and no articles show up at all, checked or unchecked. Any ideas? Thanks. Haven't used checkboxes before. Link to comment Share on other sites More sharing options...
ryan Posted January 16, 2012 Share Posted January 16, 2012 Your display_options in the selector needs one of the following: The literal $page object for page 'not-shown-on-front-page' The full path to the page you are trying to match The ID of the page you are trying to match As a result, I'm thinking you'd want to do this (use the path rather than the name): $stores = $pages->get('/news/co-op-news')->children('limit=4, display_options!=/tools/display-options/not-shown-on-front-page'); If you aren't going to have a ton of display_options, you might also want to consider just using single checkbox fields for these, in which case you could just do this: not_shown_on_front_page=0 1 Link to comment Share on other sites More sharing options...
MarcC Posted January 16, 2012 Author Share Posted January 16, 2012 Thanks, Ryan. I switched display_options to a single checkbox (bool). However, both checked and unchecked items are hidden now. See anything wrong with this? $stories = $pages->get('/news/co-op-news')->children("limit=4, display_options=0"); (Will probably change the field name later so it's more specific) Link to comment Share on other sites More sharing options...
apeisa Posted January 16, 2012 Share Posted January 16, 2012 (edited) Hidden pages don't come up in selectors, which return multiple pages PageArray (=find, children, etc). You can include those by adding "include=hidden" to your selector. EDIT: Not sure if I am on the same map at all . Your selector looks fine to me, should include only pages with display_options unchecked. Sometimes when you develop (edit and rename tempaltes, fields etc) pw can go dizzy on selectors (caches results I assume?). Try saving the parent page. That is very rare (happened me maybe once or twice) and not sure if that is the case here. Edited January 16, 2012 by apeisa I was talking about totally different thing earlier. Link to comment Share on other sites More sharing options...
MarcC Posted January 16, 2012 Author Share Posted January 16, 2012 Oh, looks like it's working now. Sorry! Thanks for the responses. 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