Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Blog Module /

Discuss the Blog Module.

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

Remove Author Field


Go to End


12 Posts   4345 Views

Avatar
Mo

Community Member, 541 Posts

17 March 2011 at 12:13am

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

Avatar
Juanitou

Community Member, 323 Posts

17 March 2011 at 2:57am

Edited: 17/03/2011 3:01am

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

Avatar
Mo

Community Member, 541 Posts

17 March 2011 at 3:07am

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

Avatar
Juanitou

Community Member, 323 Posts

17 March 2011 at 3:34am

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…

Avatar
Juanitou

Community Member, 323 Posts

17 March 2011 at 3:36am

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

Avatar
Mo

Community Member, 541 Posts

17 March 2011 at 3:42am

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

Avatar
Mo

Community Member, 541 Posts

17 March 2011 at 3:56am

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

Avatar
mierla

Community Member, 16 Posts

27 June 2011 at 5:08am

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.

Go to Top