PCuser Posted August 23, 2018 Share Posted August 23, 2018 I have the template: categories-template.php And the select multiple choice checkbox field: categoryoptions1 - red2 - blue 3 - green And 3 pages (using the template categories-template.php) redpage (with the page id 1120 & the checkbox 'red' checked off on the field categoriesoptions)bluepage (with the page id 1130 & the checkbox 'blue' checked off on the field categoriesoptions)greenpage (with the page id 1140 & the checkbox 'green' checked off on the field categoriesoptions) When I try to target the blue page with: <?php echo $pages->find("template=categories-template, artcategories=2"); ?> I receive the right page ID, in the above example it outputs the id '1130'. But <?php echo $pages->find("template=categories-template, artcategories=2")->url; ?> Doesn't get the page URL of bluepage, it just returns the URL of the current page that it is on. Any suggestions? I've been troubleshooting this longer than I'd like to admit lol. Thanks Link to comment Share on other sites More sharing options...
Robin S Posted August 23, 2018 Share Posted August 23, 2018 $pages->find() returns a PageArray, and you can't get the URL of a PageArray. I think you want $pages->get() or $pages->findOne(). I recommend checking that a real page is returned before trying to get its URL. $p = $pages->findOne("template=categories-template, artcategories=2"); if($p->id) { // Page was found, output its URL, etc } else { // No page found, so deal with this somehow } 1 Link to comment Share on other sites More sharing options...
PCuser Posted August 23, 2018 Author Share Posted August 23, 2018 Thank you! findOne worked, I had tried get() instead of find() but it didn't work out. And oops messed up my code example I gave by leaving wrong field name (artcategories should be categoryoptions) 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