Jump to:

1851 Posts in 1606 Topics by 561 members

Blog Module

SilverStripe Forums » Blog Module » Remove Author Field

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 2190 Views
  • Mo
    Community Member
    508 Posts

    Re: Remove Author Field Link to this post

    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.


  • mierla
    Community Member
    16 Posts

    Re: Remove Author Field Link to this post

    Hey... that's a thought. I think I'll give that a shot - thanks!

  • mierla
    Community Member
    16 Posts

    Re: Remove Author Field Link to this post

    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!

  • webmanj
    Community Member
    7 Posts

    Re: Remove Author Field Link to this post

    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(){
       $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.


Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.