mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Set default author
The default author did not work, at least on my installation. I believe this is a better solution (although of course you can argue whether it should be getName() or FirstName).
This commit is contained in:
parent
8b28a1d047
commit
fcdf9d325a
@ -44,19 +44,19 @@ class BlogEntry extends Page {
|
||||
static $allow_wysiwyg_editing = true;
|
||||
|
||||
/**
|
||||
* Overload so that the default date is today.
|
||||
* Overload so that the default date is today and the default author is the logged in Member.
|
||||
*/
|
||||
public function populateDefaults(){
|
||||
parent::populateDefaults();
|
||||
|
||||
$this->setField('Date', date('Y-m-d H:i:s', strtotime('now')));
|
||||
$this->setField('Author', Member::currentUser() ? Member::currentUser()->getName() : '');
|
||||
}
|
||||
|
||||
function getCMSFields() {
|
||||
Requirements::javascript('blog/javascript/bbcodehelp.js');
|
||||
Requirements::themedCSS('bbcodehelp');
|
||||
|
||||
$firstName = Member::currentUser() ? Member::currentUser()->FirstName : '';
|
||||
$codeparser = new BBCodeParser();
|
||||
|
||||
SiteTree::disableCMSFieldsExtensions();
|
||||
@ -71,7 +71,7 @@ class BlogEntry extends Page {
|
||||
$fields->addFieldToTab("Root.Main", $dateField = new DatetimeField("Date", _t("BlogEntry.DT", "Date")),"Content");
|
||||
$dateField->getDateField()->setConfig('showcalendar', true);
|
||||
$dateField->getTimeField()->setConfig('timeformat', 'H:m:s');
|
||||
$fields->addFieldToTab("Root.Main", new TextField("Author", _t("BlogEntry.AU", "Author"), $firstName),"Content");
|
||||
$fields->addFieldToTab("Root.Main", new TextField("Author", _t("BlogEntry.AU", "Author")),"Content");
|
||||
|
||||
if(!self::$allow_wysiwyg_editing) {
|
||||
$fields->addFieldToTab("Root.Main", new LiteralField("BBCodeHelper", "<div id='BBCode' class='field'>" .
|
||||
|
Loading…
Reference in New Issue
Block a user