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
067003a6c3
commit
852b0cf440
@ -44,19 +44,19 @@ class BlogEntry extends Page {
|
|||||||
static $allow_wysiwyg_editing = true;
|
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(){
|
public function populateDefaults(){
|
||||||
parent::populateDefaults();
|
parent::populateDefaults();
|
||||||
|
|
||||||
$this->setField('Date', date('Y-m-d H:i:s', strtotime('now')));
|
$this->setField('Date', date('Y-m-d H:i:s', strtotime('now')));
|
||||||
|
$this->setField('Author', Member::currentUser() ? Member::currentUser()->getName() : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
Requirements::javascript('blog/javascript/bbcodehelp.js');
|
Requirements::javascript('blog/javascript/bbcodehelp.js');
|
||||||
Requirements::themedCSS('bbcodehelp');
|
Requirements::themedCSS('bbcodehelp');
|
||||||
|
|
||||||
$firstName = Member::currentUser() ? Member::currentUser()->FirstName : '';
|
|
||||||
$codeparser = new BBCodeParser();
|
$codeparser = new BBCodeParser();
|
||||||
|
|
||||||
SiteTree::disableCMSFieldsExtensions();
|
SiteTree::disableCMSFieldsExtensions();
|
||||||
@ -71,7 +71,7 @@ class BlogEntry extends Page {
|
|||||||
$fields->addFieldToTab("Root.Main", $dateField = new DatetimeField("Date", _t("BlogEntry.DT", "Date")),"Content");
|
$fields->addFieldToTab("Root.Main", $dateField = new DatetimeField("Date", _t("BlogEntry.DT", "Date")),"Content");
|
||||||
$dateField->getDateField()->setConfig('showcalendar', true);
|
$dateField->getDateField()->setConfig('showcalendar', true);
|
||||||
$dateField->getTimeField()->setConfig('timeformat', 'H:m:s');
|
$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) {
|
if(!self::$allow_wysiwyg_editing) {
|
||||||
$fields->addFieldToTab("Root.Main", new LiteralField("BBCodeHelper", "<div id='BBCode' class='field'>" .
|
$fields->addFieldToTab("Root.Main", new LiteralField("BBCodeHelper", "<div id='BBCode' class='field'>" .
|
||||||
|
Loading…
Reference in New Issue
Block a user