Jump to:

1844 Posts in 1600 Topics by 559 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: 2130 Views
  • Mo
    Avatar
    Community Member
    505 Posts

    Remove Author Field Link to this post

    Hi All,

    Been a while since I have posted, but I am having an issue with the Blog module. Basically, when I try and add a Blog Entry in the CMS, the Author field is not pre-populated and has to be manually updated each post.

    Is it possible to get this to be pre-populated? Looking at the code it looks like it is supposed to be.

    If that fails, is there is a way of removing it, and instead relying on the Author assigned in sitetree_versions?

    Cheers in advance,

    Mo

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: Remove Author Field Link to this post

    Hi Mo,

    That’s easy. In your mysite\_config.php, add:
    BlogEntry::$defaults = array('
    Author' => 'Your Default Author',
    'ProvideComments' => true,
    'ShowInMenus' => false
    );

    Hope it helps,
    Juan

  • Mo
    Avatar
    Community Member
    505 Posts

    Re: Remove Author Field Link to this post

    Hi Juan,

    Thanks for the reply. I didn't know you could alter defaults like that.

    Trouble is though that there will be more than one person posting blog stories through the CMS and I would like to detect who they are and fill in the field dynamically.

    The funny thing is the front end form does this, but this does not let you attach images or links in the WYSIWYG editor, so it is not really ideal.

    Cheers for the help so far!

    Mo

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: Remove Author Field Link to this post

    I didn't know you could alter defaults like that.
    Me neither, I have just discovered it!

    It’s really strange… I’ve done some debugging and it seems that you cannot add a default value to that "Author" TextField through getCMSFields(). Just try adding a test TextField with a random default value or the $firstName of the current user, and you’ll see it works.

    Maybe you have found a bug…

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: Remove Author Field Link to this post

    By the way, maybe Member::currentUser()->FirstName works in the context of the _config.php file…

  • Mo
    Avatar
    Community Member
    505 Posts

    Re: Remove Author Field Link to this post

    Nope, config.php is called to soon and so is unable to get info from the database .

    I have also tried replacing the Author field in getCMSFields (as you have) and have had similar results. It is quite a head scratcher!!

    Mo

  • Mo
    Avatar
    Community Member
    505 Posts

    Re: Remove Author Field Link to this post

    I have even tried removing and re-adding the field using an extension of DataObjectDecorator, it still appears empty.

    This is very odd!

    Anyone have any ideas? Is this a bug?

    Cheers,

    Mo

  • mierla
    Avatar
    Community Member
    16 Posts

    Re: Remove Author Field Link to this post

    Mo, did you ever get this figured out? I tried decorating the BlogEntry class to has_one Member, but mostly made a royal mess of everything.

    Love to hear if you found a solution.

    2130 Views
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.