7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Need help to show dataobject on page
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 1959 Views |
-
Need help to show dataobject on page

12 September 2010 at 4:04am Last edited: 12 September 2010 4:07am
Made some things for real estate website
Nimekiri.php (Page type)
<?php
class Nimekiri extends Page
{
static $has_many = array (
'Objektid' => 'Objekt'
);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 ObjektList() {
return DataObject::get("Objekt");
}}
?>Objekt.php (Dataobject)
<?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
);
}
}
?> -
Re: Need help to show dataobject on page

12 September 2010 at 4:08am Last edited: 12 September 2010 4:31am
Made it using example from EmployeePage and Employee
but on that code is not the page template .ss descriptionSome explaining also:
in the nimiekiri.php
Objekt = Realestate object
Objektinimi = The name of realestate object
Kirjeldus = The description of realestate objectin the objekt.php
Objektinimi = The name of realestate object
Kirjeldus = The description of realestate object
Hind = Realestate object price
Elamutyyp = The type of realestate object
Soojaveetyyp = The type of hotwater making in realestate object
Kyttetyyp = The type of heating in realestate object
Tubadearv = number of rooms in object 1-5 or more
Yldpind = Space in Realestate object
Objektinimi = The name of realestate object
Korrus = floor number
Vannitube = how many bathrooms
Tualette = how many toilets
Aadress, Linn, Vald, Maakond = the adress, city, region, state of the objekthow i need them do work u can see on page http://www.vspalvelut.fi/uusweb/korterid/ (its made without dataobjects and is not filter searchable thats why i made the new one)
first there is the objectlist and when u click on object u can see the information.
like it do use like i made the earlier version what was without dataobjects.
-
Re: Need help to show dataobject on page

12 September 2010 at 7:49pm
have you tried this?:
http://www.ssbits.com/using-silverstripe-url-parameters-to-display-dataobjects-on-a-page/
Cheers
-
Re: Need help to show dataobject on page

12 September 2010 at 9:06pm Last edited: 12 September 2010 9:31pm
Tried it but maybe im too newbie to understand it.
If u understand maybe u can help me with this.the function objektlist lets me show the titles, picture. but not the link to the objekt
-
Re: Need help to show dataobject on page

12 September 2010 at 10:34pm Last edited: 13 September 2010 12:13am
Need to show them like so:
nimekiri
objekt-1
objekt-2
objekt-3
nimekiri-2
objekt-1
objekt-2
objekt-3and so on
Can someone please help me out
-
Re: Need help to show dataobject on page

14 September 2010 at 1:46am Last edited: 14 September 2010 1:46am
Hi Webdoc,
This tutorial covers DataObject relations:
http://doc.silverstripe.org/tutorial:5-dataobject-relationship-management
In your case you can use something like this in a template
in Nimekiri.ss:
<% if Objektid %>
<% control Objektid %>
<h2>$Objektinimi</h2>
$Kirjeldus
<% end_control %>
<% end_if %> -
Re: Need help to show dataobject on page

14 September 2010 at 3:02am
this i know but is there a way to show the whole objekt in in new page like objekt 1 in mysite.com/nimekiri/objekt1
| 1959 Views | ||
| Go to Top | Next > |


