Hey all,
So I have a section on the home page of the site I'm building which is supposed to allow the admin to enter a reference number in a box on the CMS, such that when the page is rendered it will find a page of type Product or MultipleSizeProduct with that reference number and return that page so I can display the associated image for a featured design page.
I'm most of the way there, but having a little trouble. I wrote a function to return that child:
function FirstItem() {
return = DataObject::get("Product", "ReferenceNumber = " . $this->FeaturedItemOne);
}
With template code:
<% control FirstItem %>
// do stuff in here
<% end_control %>
This works fine, but I also want it to be able to find a MultipleSizeProduct with $ReferenceNumber equal to $this->FeaturedItemOne, and be able to fail gracefully if the administrator puts in a reference number that doesn't match any product (displaying nothing would be fine)... I just don't want the "Error: the webserver has not been able to respond to your request" error. I tried to do something like this:
function FirstItem() {
$do = DataObject::get("Product", "ReferenceNumber = " . $this->FeaturedItemOne);
if ($do.isEmpty()) $do = DataObject::get("MultiSizeProduct", "ReferenceNumber = " . $this->FeaturedItemOne);
if (!$do.isEmpty()) return $do;
else return false;
}
But isEmpty() is not recognized for some reason. This seems like it should be a pretty easy answer for someone who's well versed in the data model. Anyone? :)