+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Need Author for blog posts

Need Author for blog posts

13 posts, 0 answered
  1. Dinesh
    Dinesh avatar
    46 posts
    Registered:
    03 Aug 2009
    29 Oct 2009
    Link to this post
    Hi,

    In Blogs, I would like to have an author for each post I publish similar to the one in Generic Content where each content item is having an Author field. There is author field for Blog and not for posts and every post is published with the same author name.
    How can I have an author field for each post?


    -Dinesh
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Oct 2009
    Link to this post
    Hello Dinesh,

    Generally the idea is that each blog has author. And each post uses the Blog Author. A possible solution is creating a new metakey in PostEditView and PostNewView external templates. Then you need to map the external mode templates ListPageMaster and ListPageDetails and add a new contor that will show the post author instead of the blog author.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    30 Nov 2009
    Link to this post
    Ivan,

    It sounds like this would accomplish my goals--to specify a author per post, and also a link to that author's profile page. We'll be using this for guest bloggers. 

    Could you provide an example of creating a new metakey in the PostEditView and PostNewView external templates?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Nov 2009
    Link to this post
    Hello Connections Academy Developer,

    You can take a look at our UserManual - section "Adding Custom Fields". Then you can get the custom metakey using content object GetMetaData method and pass the custom fields as string. You can also create an additional fields for the blogger page, so that you will be able to retreive it from the metadata as well.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    30 Nov 2009
    Link to this post
    (Sorry Dinesh, for hijacking your thread)

    Thanks Ivan, that worked for me. It appears there would be a different process for adding an extra meta field to the BlogSettingsView control... would I have to wrap the BlogEditor control, and programatically add my field to it?


  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    01 Dec 2009
    Link to this post
    Hello Connections Academy Developer,

    Thank you for using our services.

    Metafields are added to Blog Posts, not to Blogs themselves. Blogs are the parents of Blog Posts. Blog items already have Author property which is publicly accessible once you get an instance of a blog. The author field for blog posts should be added to the content metafields control item template in the PostNew.ascx and PostEdit.ascx:
    <sf:ContentMetaFields ID="MetaFields" runat="server">
        <ItemTemplate>
           ...
        </ItemTemplate>
    </sf:ContentMetaFields>


    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Leonard
    Leonard avatar
    19 posts
    Registered:
    01 Dec 2005
    23 May 2010
    Link to this post
    Dinesh,

    If still needed, here's a 2-part set of blog posts that describe how to implement author maintenance on a blog post level, and how to customize the built-in BlogPosts control to allow filtering by the post author:

    - Admin view: enable author maintenance on the blog post level
    - Public view: new controls for Blog Posts, and Bloggers List that allow filtering by author

    I hope it helps --
  8. Cameron
    Cameron avatar
    42 posts
    Registered:
    27 Jul 2009
    10 Aug 2010
    Link to this post
    Thanks for posting the link to your article Leonard. It has gotten me on the right path. Do you, or anyone else, know the best way to record the author's name automatically (HttpContext.Current.User.Identity.Name for example) and NOT allow them to manually input a name?
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Aug 2010
    Link to this post
    Hello Michael Buchsbaum,

    You can use UserManager.GetCurrentUserName();

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Cameron
    Cameron avatar
    42 posts
    Registered:
    27 Jul 2009
    10 Aug 2010
    Link to this post
    Thanks Ivan - not to sound really ignorant, but where exactly does that go? I can't find the code that actually does the saving of the blog post.

    Thanks!
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Aug 2010
    Link to this post
    Hi Michael Buchsbaum,

    By default, blog posts are created from the backend through PostNew view and PostEdit view.  To set the author metakey for a blog post you can map external templates PostNew.ascx and PostEdit.ascx. You cna subscribe for saveButton1.Click and save the metafield by using SetMetaData method of the content item. Another option is creating a custom classes that inherit from PostNewView and PostEditView view. Then override SaveContent() method and again save the content item and its metakey by using SetMetaData method.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Leonard
    Leonard avatar
    19 posts
    Registered:
    01 Dec 2005
    11 Aug 2010
    Link to this post
    Hi Michael,

    That's a great suggestion!

    I updated the original article with a possible implementation for an "author default value" based on the current user profile - please see section 1.3

    Here's a summary of the new functionality:
    • Create New Post: set default value for Author Name to First Name / Last Name as set in the profile of the current user. These profile properties are not mandatory, as a result we'll only disable the field if the profile First Name / Last Name are non-empty. The author name will always be available for editing (enabled) if the current user is part of the "administrators" role.
    • Edit Existing Post: if a value is already set for Author Name, we'll just disable / enable the field if the user is not / is part of the "administrators" role. If the Author Name is not set (this would be the case with blog posts created before implementing the functionality described in the original article), the behaviour will be identical with the new post creation described above.
  13. Cameron
    Cameron avatar
    42 posts
    Registered:
    27 Jul 2009
    11 Aug 2010
    Link to this post
    Awesome! Thanks guys and very much to you Leonard. I was able to get that in place, make some minor changes I needed for my situation, and viola!

    If I could award you points myself I would :)

    Thanks again,
    Michael
Register for webinar
13 posts, 0 answered