@Banal, i will check your method in a sec..
for now it is solved. I didnt used the template because it was not working. and when viewing online (with the public function) <img> tags were closed by a slash <img height="567" />
this was illegal for the xml, so another reason to NOT use a template for xml.
example can be found here (temporary):
http://www.robvaneckdesign.nl/pageflip/
for the people who wan to know how i did it:
<?php
class Flyer extends Page {
static $has_many = array (
'FlyerPaginas' => 'FlyerPagina'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this,
'FlyerPaginas', // relation name
'FlyerPagina', // class name of the DataObject
'Image', // name of the file relation in the DataObject
array(
'Title' => 'Title',
// 'Comment' => 'Comment',
), // headings
'getCMSFields_forPopup' // name of the function for the popup fields
);
$fields->removeFieldFromTab('Root.Content.Main','Content');
$fields->addFieldToTab('Root.Content.Images', $manager);
return $fields;
}
public function onAfterWrite(){
parent::onAfterWrite();
$dom = new DomDocument('1.0');
$implementation = new DOMImplementation();
$dtd = $implementation->createDocumentType('xml',
'DOCTYPE book SYSTEM',
'http://www.megazine3.de/megazine2.dtd');
$dom = $implementation->createDocument('', '', $dtd);
$book = $dom->appendChild($dom->createElement('book'));
$plugins = $book->appendChild($dom->createAttribute('plugins'));
$plugins2 = $plugins->appendChild($dom->createTextNode('zoom, keyboardnavigation, navigationbar, swfaddress'));
$pagewidth = $book->appendChild($dom->createAttribute('pagewidth'));
$pagewidth2 = $pagewidth->appendChild($dom->createTextNode('567'));
$pageheight = $book->appendChild($dom->createAttribute('pageheight'));
$pageheight2 = $pageheight->appendChild($dom->createTextNode('567'));
$lang = $book->appendChild($dom->createAttribute('lang'));
$lang2 = $lang->appendChild($dom->createTextNode('en'));
$zoomminscale = $book->appendChild($dom->createAttribute('zoomminscale'));
$zoomminscale2 = $zoomminscale->appendChild($dom->createTextNode('0.5'));
$zoommaxscale = $book->appendChild($dom->createAttribute('zoommaxscale'));
$zoommaxscale2 = $zoommaxscale->appendChild($dom->createTextNode('2.0'));
$zoomsnap = $book->appendChild($dom->createAttribute('zoomsnap'));
$zoomsnap2 = $zoomsnap->appendChild($dom->createTextNode('0.5, 1.0, 1.5, 2.0'));
$zoomsteps = $book->appendChild($dom->createAttribute('zoomsteps'));
$zoomsteps2 = $zoomsteps->appendChild($dom->createTextNode('0.5'));
$dragrange = $book->appendChild($dom->createAttribute('dragrange'));
$dragrange2 = $dragrange->appendChild($dom->createTextNode('20'));
$qualitycontrol = $book->appendChild($dom->createAttribute('qualitycontrol'));
$qualitycontrol2 = $qualitycontrol->appendChild($dom->createTextNode('true'));
$thumbscale = $book->appendChild($dom->createAttribute('thumbscale'));
$thumbscale2 = $thumbscale->appendChild($dom->createTextNode('0.35'));
$cornerhint = $book->appendChild($dom->createAttribute('cornerhint'));
$cornerhint2 = $cornerhint->appendChild($dom->createTextNode('true'));
$pagethickness = $book->appendChild($dom->createAttribute('pagethickness'));
$pagethickness2 = $pagethickness->appendChild($dom->createTextNode('0.1'));
$shadows = $book->appendChild($dom->createAttribute('shadows'));
$shadows2 = $shadows->appendChild($dom->createTextNode('0.3'));
$startpage = $book->appendChild($dom->createAttribute('startpage'));
$startpage2 = $startpage->appendChild($dom->createTextNode('1'));
$centercovers = $book->appendChild($dom->createAttribute('centercovers'));
$centercovers2 = $centercovers->appendChild($dom->createTextNode('false'));
$pageoffset = $book->appendChild($dom->createAttribute('pageoffset'));
$pageoffset2 = $pageoffset->appendChild($dom->createTextNode('0'));
$chapter = $book->appendChild($dom->createElement('chapter'));
foreach($this->FlyerPaginas() as $FlyerPagina) {
$page = $chapter->appendChild($dom->createElement('page'));
$img = $page->appendChild($dom->createElement('img'));
$width = $img->appendChild($dom->createAttribute('width'));
$width2 = $width->appendChild($dom->createTextNode('567'));
$height = $img->appendChild($dom->createAttribute('height'));
$height2 = $height->appendChild($dom->createTextNode('567'));
//Zoom level 0,5
$src1 = $img->appendChild($dom->createElement('src'));
$scaleA = $src1->appendChild($dom->createAttribute('scale'));
$scaleB = $scaleA->appendChild($dom->createTextNode('0.5'));
$src1 ->appendChild(
$dom->createTextNode($FlyerPagina->Image()->SetWidth(284)->URL)
);
//Zoom level 0,75
$src5 = $img->appendChild($dom->createElement('src'));
$scaleX = $src5->appendChild($dom->createAttribute('scale'));
$scaleY = $scaleX->appendChild($dom->createTextNode('0.75'));
$src5 ->appendChild(
$dom->createTextNode($FlyerPagina->Image()->SetWidth(433)->URL)
);
//Zoom level 1,0
$src2 = $img->appendChild($dom->createElement('src'));
$scaleC = $src2->appendChild($dom->createAttribute('scale'));
$scaleD = $scaleC->appendChild($dom->createTextNode('1.0'));
$src2 ->appendChild(
$dom->createTextNode($FlyerPagina->Image()->SetWidth(567)->URL)
);
//Zoom level 1,5
$src3 = $img->appendChild($dom->createElement('src'));
$scaleE = $src3->appendChild($dom->createAttribute('scale'));
$scaleF = $scaleE->appendChild($dom->createTextNode('1.5'));
$src3 ->appendChild(
$dom->createTextNode($FlyerPagina->Image()->SetWidth(850)->URL)
);
//Zoom level 2,0
$src4 = $img->appendChild($dom->createElement('src'));
$scaleG = $src4->appendChild($dom->createAttribute('scale'));
$scaleH = $scaleG->appendChild($dom->createTextNode('2.0'));
$src4 ->appendChild(
$dom->createTextNode($FlyerPagina->Image()->SetWidth(1134)->URL)
);
}
//generate xml
$dom->formatOutput = true; // set the formatOutput attribute of
// domDocument to true
// save XML as string or file
$test1 = $dom->saveXML(); // put string in test1
$dom->save('megazine.mz3'); // save as file - add absolute path
}
}
class Flyer_Controller extends Page_Controller {
}
class FlyerPagina extends DataObject {
static $db = array (
'Title' => 'Text',
// 'Comment' => 'HTMLText',
);
static $has_one = array (
'Image' => 'Image',
'Flyer' => 'Flyer'
);
public function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push(new TextField('Title'));
//$fields->push(new SimpleTinyMCEField('Comment'));
$fields->push(new FileUploadField('Image','Upload files'));
return $fields;
}
}