3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1797 Views |
-
What field type should I use for rich text?

25 March 2009 at 12:43am
Hi,
I want to add another field to my Content tab in the CMS editor. I would like it to have rich text like the Content field. What field type should I be defining in the class for $db and in getCMSFields? I can't find anything like RichTextField - is this field type available?
The reason I don't want to just use the Content field is that I want to make a teaser to use elsewhere and want to control case by case precisely what is in the teaser, including rich text (which is why I don't want to use$Description.LimitWordCount(xx)).
Thanks for any advice,
Ian.
-- -
Re: What field type should I use for rich text?

25 March 2009 at 2:50am
I figured it out: if anyone else is interested, the type to use in the class is "HTMLText", and the type to use in getCMSFields is "HTMLEditorField", like so:
class ContentBlockPage extends Page {
static $db = array(
'ColumnRef' => 'Text',
'RowNumber' => 'Int',
'BlockColour' => 'Text',
'TeaserText' => 'HTMLText'
);
static $has_one = array(
'TeaserImage' => 'Image'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('ColumnRef'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new NumericField('RowNumber'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('BlockColour'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new HTMLEditorField('TeaserText'), 'Content');
$fields->addFieldToTab('Root.Content.Images', new ImageField('TeaserImage'));
return $fields;
}
}
| 1797 Views | ||
|
Page:
1
|
Go to Top |

