17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1762 Views |
-
How do add an additional 'Content' box to SS?

8 September 2008 at 4:59am Last edited: 8 September 2008 5:20am
I have added a box to my CMS using a HomePage.php page. When I view the 'Scroller' box in the CMS it is only a single line long and is only text. Please would someone let me know how to get the functionality and size of the 'Content' box in an additional input box.
Many thanks
Michelleclass HomePage extends Page {
static $db = array(
'Scroller' => 'Text'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('Scroller'), 'Content');
return $fields;
}
static $has_one = array(
);
}class HomePage_Controller extends Page_Controller {
} -
Re: How do add an additional 'Content' box to SS?

8 September 2008 at 5:52am
Change it to the htmltext type.
'Scroller' => 'HTMLText'
Then,
$fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('Scroller'), 'Content');
http://doc.silverstripe.com/doku.php?id=htmleditorfield
You can see all the ones you can use in the docs.
-
Re: How do add an additional 'Content' box to SS?

8 September 2008 at 6:05am
That worked an absolute treat. Thank you so much LeeUmm.
Cheers
Michelle -
Re: How do add an additional 'Content' box to SS?

10 September 2008 at 8:16am Last edited: 10 September 2008 8:16am
I've been trying to do the same (following along with the tutorials)... and I can see the new fields in the CMS, but they aren't saving to the database (except the team photo). The variables are unique as far as I can tell:
<?php
class TeamPage extends Page {
static $db = array(
);
static $has_one = array(
'Photo' => 'Image',
'JobPosition' => 'Text',
'JobTitle' => 'Text',
'JobLocation' => 'Text'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('JobPosition'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('JobTitle'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('JobLocation'), 'Content');
$fields->addFieldToTab('Root.Content.Images', new ImageField('Photo'));
return $fields;
}
}class TeamPage_Controller extends Page_Controller {
}
?> -
Re: How do add an additional 'Content' box to SS?

10 September 2008 at 8:22am
You need to put those fields in the $db array, not the has_one array unless you're building relationships between pages. Leave the photo in the has_one though.
Then run domain.com/db/flush=1
-
Re: How do add an additional 'Content' box to SS?

10 September 2008 at 8:26am
The code should be something like this:
static $db = array(
'Photo' => 'Image',
'JobPosition' => 'Text',
'JobTitle' => 'Text',
'JobLocation' => 'Text'
); -
Re: How do add an additional 'Content' box to SS?

10 September 2008 at 8:27am
beautiful!!! thanks liam.
starting to really like silverstripe, just gotta get a little further over this hump.
-
Re: How do add an additional 'Content' box to SS?

10 September 2008 at 12:16pm
Ok, now I'm stuck again.
I tried adding more than one image to static $db = array( and it threw a bunch of errors. But everything works fine if I only have one image located in: static $has_one = array(
| 1762 Views | ||
|
Page:
1
|
Go to Top |


