I have done this:
class DesktopItemsPage extends Page {
...
static $has_one = array(
'Pic1' => 'Image',
);
...
}
class DesktopItemsPage_Controller extends Page_Controller {
}
class Desktop_Image extends Image {
static $db = null;
function generateDesktopSmall($gd) {
$gd->setQuality(90);
return $gd->paddedResize(800,600);
}
function generateDesktopMedium($gd) {
$gd->setQuality(90);
return $gd->paddedResize(1024,768);
}
}
my template looks as follows (note that it uses child pages that each have a desktop stored in them as an image...). Thus, the actual page you are on is not a desktopItemsPage but a desktopPage.
<% control Children %>
<div class="desktop">
$Pic1.SetWidth(147)
<a href="$DesktopSmall.URL">800x600</a>
<a href="$DesktopMedium.URL">1024x768</a>
<a href="$Pic1.URL">1280x1024</a>
</div>
<% end_control %>
This does not seem to work (there are no links to small and medium image). Then I changed
'Pic1' => 'Image',
to
'Pic1' => 'Desktop_Image',
But that was even less successful - image was lost in its entirety.
Where am I going wrong?
Thank you
Nicolaas