1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » Remove Author Field
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | ||
| Author | Topic: | 1675 Views |
-
Re: Remove Author Field

27 June 2011 at 5:24am
Unfortunately not! I have tried a few different approaches and all of them have proven in-effective.
Looking at the source code, it looks like the BlogEntry class is supposed to have the current logged in user pre-populated in the Author field, but for some reason that doesn't seem to work.
The only other thing I could think that you could do would be to generate a dropdown of all members (possibly filtered by a group, say 'blog-editors') and replace the existing author field with that.
Mo
-
Re: Remove Author Field

27 June 2011 at 5:27am
Hey... that's a thought. I think I'll give that a shot - thanks!
-
Re: Remove Author Field

27 June 2011 at 6:30am
It worked! (I think; haven't tested front-end editing yet)
I edited BlogEntry directly, which I know is a no-no. Now that I've got it working, I may try to go back to stock there and properly extend the BlogEntry class.So here's what I did:
I removed Author from the db array, and added it as a has_one, then added this to the getCMSFields function:
$fields->addFieldToTab("Root.Content.Main", new DropdownField('AuthorID', 'Please choose an author', Dataobject::get("Member")->map("ID", "FullName", $fullName)), "Content");
It *seems* to be working. I added a getComponent function, and now I can call all the Member fields from my template. Hooray! Thank you!
-
Re: Remove Author Field

1 February 2012 at 11:48pm
Hello all,
I'm a little late to the game but I do have a solution if no one has one that really works. Here's what you do:
public function populateDefaults(){
parent::populateDefaults();
$this->setField('Date', date('Y-m-d H:i:s', strtotime('now')));
$this->Author = Member::currentUser() ? Member::currentUser()->FirstName : '';
}Then, comment out OR remove/replace the following entries from getCMSFields
//$firstName = Member::currentUser() ? Member::currentUser()->FirstName : '';
//$fields->addFieldToTab("Root.Content.Main", new TextField("Author", _t("BlogEntry.AU", "Author"), $firstName),"Content");
$fields->addFieldToTab("Root.Content.Main", new TextField("Author", _t("BlogEntry.AU", "Author")),"Content");This has worked 100% of the time and I believe is the correct way to do it.
Hope this helps someone.
Thanks,
Jason
| 1675 Views | ||
| Go to Top |


