Strange but i dont get it work
used code:
nimekiri.php
<?php
class Nimekiri extends Page
{
static $has_many = array (
'Objektid' => 'Objekt'
);
static $allowed_actions = array(
'show'
);
public function getCMSFields()
{
$f = parent::getCMSFields();
$f->removeFieldFromTab("Root.Content.Main","Content");
$manager = new DataObjectManager(
$this,
'Objektid',
'Objekt',
array('Objektinimi' => 'Objekti nimi', 'Kirjeldus' => 'Objekti kirjeldus'),
'getCMSFields_forPopup'
);
$f->addFieldToTab('Root.Content.Main', $manager);
return $f;
}
}
class Nimekiri_Controller extends Page_Controller {
function init(){
parent::init();
}
function show($request){
if($request->param('ID')){
$obj = DataObject::get_by_id('Objekt', (int)$request->param('ID'));
return $this->customise($obj)->renderWith(array('Nimekri'));
}
}
}
?>
objekt.php:
<?php
class Objekt extends DataObject
{
static $db = array (
'Objektinimi' => 'Text',
'Kirjeldus' => 'HTMLText',
'Hind' => 'Text',
'Elamutyyp' => "Enum('Korter, Maja, Aripind, Suvila, Ridaelamu, Paarismaja, Maatykk')",
'Soojaveetyyp' => "Enum('Keskkyte, Elekter')",
'Kyttetyyp' => "Enum('Keskkyte, Elekter, Puukyte')",
'Tubadearv' => "Enum('1, 2, 3, 4,5,rohkem')",
'Krundisuurus' => 'Text',
'Yldpind' => 'Text',
'Korrus' => 'Text',
'Vannitube' => 'Text',
'Tualette' => 'Text',
'Aadress' => 'Text',
'Linn' => 'Text',
'Vald' => 'Text',
'Maakond' => 'Text'
);
static $has_one = array (
'Nimekiri' => 'Nimekiri',
'Photo' => 'Image'
);
static $has_many = array (
'GalleryImages' => 'GalleryImage'
);
static $searchable_fields = array(
'Elamutyyp' => 'ExactMatchFilter',
'Yldpind' => 'ExactMatchFilter',
'Linn' => 'ExactMatchFilter',
'Tubadearv' => 'ExactMatchFilter'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Objektinimi'),
new SimpleWysiwygField('Kirjeldus'),
new DropdownField(
'Elamutyyp',
'Elamutyyp',
singleton('Objekt')->dbObject('Elamutyyp')->enumValues()),
new DropdownField(
'Soojaveetyyp',
'Soojaveetyyp',
singleton('Objekt')->dbObject('Soojaveetyyp')->enumValues()),
new DropdownField(
'Kyttetyyp',
'Kyttetyyp',
singleton('Objekt')->dbObject('Kyttetyyp')->enumValues()),
new TextField('Hind'),
new TextField('Krundisuurus'),
new TextField('Yldpind'),
new DropdownField(
'Tubadearv',
'Tubadearv',
singleton('Objekt')->dbObject('Tubadearv')->enumValues()),
new TextField('Korrus'),
new TextField('Vannitube'),
new TextField('Tualette'),
new ImageField('Photo'),
new TextField('Aadress'),
new TextField('Linn'),
new TextField('Vald'),
new TextField('Maakond'),
new ImageDataObjectManager(
$this,
'GalleryImages', // Source name
'GalleryImage', // Source class
'MyGalleryImage', // File name on DataObject
array('Pildinimi' => 'Pildinimi'))
);
}
public function getCustomSearchContext() {
$fields = $this->scaffoldSearchFields(array('Elamutyyp','Yldpind','Linn','Tubadearv')
);
$filters = array(
'Elamutyyp' => new ExactMatchFilter('Elamutyyp'),
'Yldpind' => new ExactMatchFilter('Yldpind'),
'Linn' => new ExactMatchFilter('Linn'),
'Tubadearv' => new ExactMatchFilter('Tubadearv')
);
return new SearchContext(
$this->class,
$fields,
$filters
);
}
function Link(){
return $this->Nimekiri()->Link() .'show/'.$this->ID;
}
}
?>
and nimekiri.ss:
<div class="typography">
<h2>$Title</h2>
<% if show %>
<% control show %>
<div class="pilt">
<table width="300" border="0">
<tr>
<td><h4>$Objektinimi</h4></td>
</tr>
<tr>
<td valign="top"><table width="300" height="130" border="0">
<tr>
<td width="130" align="left" valign="top"><a href="{$Top.URLSegment}/{$ID}" title="$Objektinimi">$Photo.SetWidth(120)</a></td>
<td align="left" valign="top">
<% if Hind %><span style="font-size:11px;"><% _t("MYYGIHIND","Müügihind") %>:<strong>$Hind</strong></span><br /><% end_if %>
<% if Yldpind %><span style="font-size:11px;"><% _t("YLDPIND","Üldpind") %>: <strong>$Yldpind</strong></span><br /><% end_if %>
<% if Krundisuurus %><span style="font-size:11px;"><% _t("KRUNT","Krundi suurus") %>: <strong>$Krundisuurus</strong></span><br /><% end_if %>
<p style="font-size:11px;"><br /><a href="$link" title="$Objektinimi"><% _t("INFO","Detailne info") %></a></p></td>
</tr>
</table></td>
</tr>
</table>
</div>
<% end_control %>
<% end_if %>
$Content
$PageComments
$Form
<div class="clear"><!-- --></div>
</div>
<div style="margin-bottom:20px;"></div>