21492 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 633 Views |
-
DataObjectGet Pagees by parent ClassName

30 August 2011 at 7:09am
How do I write a Join clause in DataObjectGet that will return all the pages that have a particular page type as the parent?
-
Re: DataObjectGet Pagees by parent ClassName

30 August 2011 at 2:58pm
SS automatically joins all the parent classes. What happens when you do DataObject::get('ParentClass') ? I think you'll get all the children objects.
-
Re: DataObjectGet Pagees by parent ClassName

30 August 2011 at 3:56pm
Is there a way to do this on a DataObject instead of a Page?
for example I have:
Category has_many SubCategory (SubCategory has_one Category)
SubCategory has_many Item (Item has_one SubCategory)Then retrieve the parent or grandparent of Item?
-
Re: DataObjectGet Pagees by parent ClassName

30 August 2011 at 4:42pm
Well thats slightly different to your earlier question.
If you have the given item, you can use the ORM to get that (it won't be lighting quick). $item->Subcategory()->Category();
If you're trying to get it via DataObject::get() then you have to write a standard SQL JOIN cause to join subcategory and category.
-
Re: DataObjectGet Pagees by parent ClassName

30 August 2011 at 4:50pm Last edited: 30 August 2011 4:54pm
Sorry, I kind of hijacked this post there. My question was different from the OP.
Thank you for that quick response @WillrApologies @micahsheets. I've sort of done what you are asking, but I've never put it with join before.
WIllr's answer is correct, I've tested it and it returns a list of children belonging to the called class.EDIT: WIllr, using $this->SubCategory()->Category() works perfectly! Love how simple it was. Thanks again.
| 633 Views | ||
|
Page:
1
|
Go to Top |



