3093 Posts in 875 Topics by 654 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 402 Views |
-
How to merge/combine fields

6 August 2011 at 5:27am
Hi,
I have created a page-controller there you can store personal data. Below you can see the code:-------------------------------------------------------------------------------------------
<?php
class Steckbrief extends Page {
static $icon = "themes/website/images/icons/steckbrief";
static $db = array(
'Name' => 'Text',
'Geburtsdatum' => 'Date',
'Anschrift' => 'Text',
'Telefon' => 'Text',
'Mobil' => 'Text',
'Email' => 'Text',
'Website' => 'Text',
'Socialnetwork' => 'Text',
'Sonstiges' => 'Text',
'Name2' => 'Text',
'Geburtsdatum2' => 'Date',
'Anschrift2' => 'Text',
'Telefon2' => 'Text',
'Mobil2' => 'Text',
'Email2' => 'Text',
'Website2' => 'Text',
'Socialnetwork2' => 'Text',
'Sonstiges2' => 'Text'
);static $has_one = array(
'Photo' => 'Image',
'Photo2' => 'Image'
);function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content', new TabSet('Personendaten'));
$fields->addFieldToTab('Root.Content.Personendaten.Person1', new TextField('Name'));
$fields->addFieldToTab('Root.Content.Personendaten.Person1', new DateField('Geburtsdatum'));
$fields->addFieldToTab('Root.Content.Personendaten.Person1', new TextField('Anschrift'));
$fields->addFieldToTab('Root.Content.Personendaten.Person1', new TextField('Telefon'));
$fields->addFieldToTab('Root.Content.Personendaten.Person1', new TextField('Mobil'));
$fields->addFieldToTab('Root.Content.Personendaten.Person1', new TextField('Email'));
$fields->addFieldToTab('Root.Content.Personendaten.Person1', new TextField('Website'));
$fields->addFieldToTab('Root.Content.Personendaten.Person1', new TextField('Socialnetwork'));
$fields->addFieldToTab('Root.Content.Personendaten.Person1', new TextField('Sonstiges'));
$fields->addFieldToTab('Root.Content.Personendaten.Person2', new TextField('Name2'));
$fields->addFieldToTab('Root.Content.Personendaten.Person2', new DateField('Geburtsdatum2'));
$fields->addFieldToTab('Root.Content.Personendaten.Person2', new TextField('Anschrift2'));
$fields->addFieldToTab('Root.Content.Personendaten.Person2', new TextField('Telefon2'));
$fields->addFieldToTab('Root.Content.Personendaten.Person2', new TextField('Mobil2'));
$fields->addFieldToTab('Root.Content.Personendaten.Person2', new TextField('Email2'));
$fields->addFieldToTab('Root.Content.Personendaten.Person2', new TextField('Website2'));
$fields->addFieldToTab('Root.Content.Personendaten.Person2', new TextField('Socialnetwork2'));
$fields->addFieldToTab('Root.Content.Personendaten.Person2', new TextField('Sonstiges2'));
$fields->addFieldToTab('Root.Content', new TabSet('Fotos'));
$fields->addFieldToTab('Root.Content.Fotos.Foto 375x500 px', new ImageField('Photo'));
$fields->addFieldToTab('Root.Content.Fotos.Foto 2 375x500 px', new ImageField('Photo2'));
return $fields;
}}
class Steckbrief_Controller extends Page_Controller {
}
?>
-------------------------------------------------------------------------------------------You can see there are Person1 and Person2 - each of them with own name: (Person1 -> Name) and (Person2 -> Name2). Also there are two birthdates: (Person1 -> Geburtsdatum) and (Person2 -> Geburtsdatum2).
Now I wold like to generate a birthdaylist sorted by date. At first - I think - I have to merge/combine the fields to have one new fieldset. Is it right? If yes, how to do? Hope, you can help me.
Thanks for your support!
-
Re: How to merge/combine fields

9 August 2011 at 8:49pm
Any reason why you have 2 people per page as a limit? If you're going to have a list of people you would be better off creating a 'Person' data object. It would make it easier to conceptualize and make your code easier to use.
The 5th tutorial provides an introduction to data objects - http://doc.silverstripe.org/sapphire/en/tutorials/5-dataobject-relationship-management
| 402 Views | ||
|
Page:
1
|
Go to Top |


