Jump to content

Can I select children with only checked checkboxes?


Paschalis
 Share

Recommended Posts

Hi all,

I try to select children with only checked checkboxes, but I haven't found a way. I want to select from DB (as selector) and not as a loop from PHP.

At the moment, I do

<?php
$homesCategory = $pages->get("id=1016")->children;
foreach ($homesCategory as $featuredProperties) {
if ($featuredProperties->featured_properties == 1) {
?>

So, If I have thousands of homes, I will have to loop through all and present only the featured. I want to select the featured through DB for speed. Something like

<?php
$featuredProperties = $pages->get("id=1016")->children->get("featured_properties=1");
?>

I know that it does not work,but I use it as an example to explain what I try to do

Thank you all

 

Link to comment
Share on other sites

Hello @Paschalis,

$featuredProperties = $pages->find("parent_id=1016, featured_properties=1");

Note that it will return only direct children of the page 1016, if you want also grand-children it's:

$featuredProperties = $pages->find("has_parent=1016, featured_properties=1");

 

Link to comment
Share on other sites

On 1/31/2024 at 6:32 PM, da² said:

Hello @Paschalis,

$featuredProperties = $pages->find("parent_id=1016, featured_properties=1");

Note that it will return only direct children of the page 1016, if you want also grand-children it's:

$featuredProperties = $pages->find("has_parent=1016, featured_properties=1");

 

Thank you so much for your help. Apparently it worked 

  • Like 1
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

×
×
  • Create New...