21294 Posts in 5734 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1287 Views |
-
can't get image Class in Page_Controller

14 March 2010 at 7:32am
I'm a little bit confused about the way I used to get the Image - Class in Page Controller.
in older Silverstripe - installations i got the Image that i defined in Page-Class via:
class Page_Controller extends ContentController {
$actPage = DataObject::get_by_id("Page", $this->ID);
return $actPage->Image()->CroppedImage(100, 100);}
im an actual installation i get an Exception: Object->__call(): the method 'image' does not exist on 'Page'
'image does not exist on Page' ?!
can anyone Help?
thanks
-
Re: can't get image Class in Page_Controller

14 March 2010 at 9:54am
Hi mtz,
What version of SS are you using? Is your $has_one association called 'Image'? If not, then the method you need to call is the Association name.
Usually, if I want to retrieve an Image, I use:
DataObject::get_by_id('Image',$this->HasOneName()->ID);
Not sure if that is the best way, but it seems to work.
Mo
-
Re: can't get image Class in Page_Controller

15 March 2010 at 12:00am
Hi Mo,
thanks! You gave me the right hint.
my has_one relation is:
static $has_one = array(
'SectionImage' => 'Image'
);so i have to call $this->SectionImage();
greets,
Mtz
| 1287 Views | ||
|
Page:
1
|
Go to Top |


