Jump to content

Recommended Posts

Posted

Hello,

I would like to check if a specific field has 0 value in ALL children of the current page and then echo for example: Sold Out.

Can you help me?

Thanks in advance!

Posted

Or little more efficent

if(!$pages->count("parent=$page, my_field=0")) {
     echo "Sold out";
}
  • Like 2
Posted

Something like this?

if(count($page->children('my_field=0')) == 0) {
    echo "Sold out";
}

Did you edit it? The first one you posted which I got in my email is working perfectly:

if(count($pages->get("$page->id")->children("my_field=0"))) {
    echo "Sold out";
}

Thank you guys both for the help!

Posted

Did you edit it? The first one you posted which I got in my email is working perfectly:

if(count($pages->get("$page->id")->children("my_field=0"))) {
    echo "Sold out";
}

Yes, I noticed that you mentioned "current page" so I thought there's no need to use get().

@kongondo

Thanks, I always suspected this but never really dived into it :)

  • Like 1
Posted

You really want to use $pages->count. count($page...) will come back and bite you when you have lots of pages... :-)

The maximum children will be about 6.

Posted

Yes, I noticed that you mentioned "current page" so I thought there's no need to use get().

@kongondo

Thanks, I always suspected this but never really dived into it :)

I have been bitten several times... ;)   (Blog Module)

Posted

You really want to use $pages->count. count($page...) will come back and bite you when you have lots of pages... :-)

I used the Soma's version just to be safe. Thanks.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...