Hi,
there is still - i think a very important - thing that i still haven't understand: In my holder page i refer to my detail objects
class ProjektCategory extends Page {
static $allowed_children = array(
'Projekt'
);
static $has_many = array(
'Projekte' => 'Projekt',
'Stammdaten' => 'Stammdaten'
);
in the detail page i manage the main informations and some references to different tables (e.g.)
<?php
class Projekt extends Page {
static $has_one = array(
'ProjektCategory' => 'ProjektCategory',
'ProjektImage' => 'Projekt_Thumbnail'
);
static $db = array(
'Monat' => 'Text',
'Datum' => 'Date',
'Kunde' => 'Int',
'Bereich' => 'Text',
'CopytextHome' => 'HTMLText',
'HeadlineHome' => 'Text'
);
function getCMSFields() {
$fields = parent::getCMSFields();
//Felder entfernen
$fields->removeFieldFromTab('Root.Content.Main', 'RedirectToChild');
$fields->removeByName("Kopfbilder");
$fields->removeByName("Banner");
$fields->addFieldToTab("Root.Content.Main", new ImageField("ProjektImage", "Vorschaubild", null, null, null, "assets/Projektbilder/"));
//$fields->addFieldToTab('Root.Content.Main', new ImageField('ProjektImage'));
$fields->addFieldToTab('Root.Content.Main', new TextField('Monat'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Datum'), 'Content');
//$fields->addFieldToTab('Root.Content.Main', new DropdownField('PageColor', 'Page Color', self::$colors), $this->PageColor);
//$fields->addFieldToTab('Root.Content.Main', new TextField('Bereich'), 'Content');
$kunden = Dataobject::get("Stammdaten")->toDropdownMap("ID", "Firmenname");
// DropdownField('field name', 'field titel', quelle, "the current value", the parent formular, "Empty Value Title");
$fields->addFieldToTab("Root.Content.Main", new DropdownField(
'Kunde',
'Firmenname',
$kunden,
null,
null,
'Bitte eine Firma waehlen'
), 'Content');
$bereich = Dataobject::get("SiteTree", "ClassName = 'ReferenzCategory'")->toDropdownMap("ID", "URLSegment");
$fields->addFieldToTab("Root.Content.Main", new DropdownField(
'Bereich',
'Projektbereich',
$bereich,
null,
null,
'Bitte einen Bereich waehlen'
), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('HeadlineHome'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextareaField('CopytextHome'), 'Content');
return $fields;
}
}
'ProjektImage' is saved to the file table:
class Projekt_Thumbnail extends Image {
public function generateThumb($gd) {
$gd = $gd->resizeByWidth(150);
$gd->setQuality(100);
return $gd;
}
}
in my .ss file i want to show the rendered informations:
<% control getJahresartikel %>
<div class="absatz">
<div class="marginalspalte" style="margin-top:0px; font-weight:bold;">
<img src="$ProjektImage.Thumb.URL" title="$FileFilename" alt="$FileFilename" class="" /></div>
<div class="contenspalte">
$Monat<br />
Thema: $Title<br />
Kunde: $Firmenname<br />
Lesen sie <a href="$URLSegment" title="Lesen sie mehr in der Rubrik $SiteTreeURLSegment." class="$LinkingMode"><span>hier</span></a> weiter.
</div>
</div>
<% end_control %>
All data is passed to the template correctly, but the thumbnail will not be generated??
I have tried to ways to build the query
function getJahresartikel() {
$jahr = $this->URLParams['URLSegment'];
$sqlQuery = DB::query("SELECT p.`ID`, p.`Datum`, DATE_FORMAT(p.`Datum`, '%M') AS ProjektMonat, p.`Kunde`, p.`Bereich`, p.`Monat`, p.`ProjektImageID`, s.`ID`, s.`Title`, s.`URLSegment`, st.`ID`, st.`Firmenname`, f.`ID`, f.`Filename`, f.`Name`, f.`ClassName` FROM `Projekt` p LEFT JOIN `SiteTree` s ON p.`ID` = s.`ID` LEFT JOIN `File` f ON f.`ID` = p.`ProjektImageID` LEFT JOIN `Stammdaten` st ON st.`ID` = p.`Kunde` WHERE DATE_FORMAT(p.`Datum`, '%Y') = ".$jahr."");
//debug::show($sqlQuery); die;
$firmen = new DataObjectSet();
foreach($sqlQuery as $row) {
$firmen->push(new ArrayData($row));
}
//var_dump($firmen);
return $firmen;
}
and
function getJahresartikel() {
$jahr = $this->URLParams['URLSegment'];
$sqlQuery = new SQLQuery();
$sqlQuery->select = array(
'Projekt.ID AS ProjektID',
'Projekt.Datum AS ProjektDatum',
'DATE_FORMAT(Projekt.Datum, "%M") AS ProjektMonat',
'Projekt.Kunde AS ProjektKunde',
'Projekt.Bereich AS ProjektBereich',
'Projekt.Monat AS Monat',
'Projekt.ProjektImageID AS ProjektImage',
//
'SiteTree.ID AS SiteTreeID',
'SiteTree.Title AS SiteTreeTitle',
'SiteTree.URLSegment AS SiteTreeURLSegment',
//
'Stammdaten.ID AS ID',
'Stammdaten.Firmenname AS Firmenname',
//
'Stammdaten.ClassName AS ClassName',
'Stammdaten.ClassName AS RecordClassName',
'File.ID AS FileID',
'File.Filename AS FileFilename'
);
$sqlQuery->from = array(
"Projekt",
"LEFT JOIN Stammdaten ON Stammdaten.ID = Projekt.Kunde LEFT JOIN SiteTree ON SiteTree.ID = Projekt.ID LEFT JOIN File ON File.ID = Projekt.ProjektImageID"
);
//debug::show($sqlQuery); die;
$result = $sqlQuery->execute();
$firmen = new DataObjectSet();
foreach($result as $row) {
$firmen->push(new ArrayData($row));
}
//var_dump($firmen);
return $firmen;
}
}
Can somebody explain how to get into the right scope and how to generate the thumb?
Thanks, Carsten