3

I have blog for our management team. Assistants will be posting instead of the managers. I have created a column called "Author" which is "people/group" lookup field for the assistants to add a person (manager) as author. Now, instead of displaying Created by column, I want to display "Author" column in blog post web part as Author: Manager Name.

But I am not able to change the web part view. Is there way to add this to a blog post? Or to add it inside a blog post body as Author: Manager Name. ?

2 Answers 2

2

I went a little different direction to fix this problem before. I created a special webpart which allowed you to configure it to create a blog post as another user. Here is the meat of the code to accomplish that:

//UserId = string of full login name of manager/person you want the blog to be created by
//listView = SPView of the blog
using (SPWeb listWeb = listView.ParentList.ParentWeb)
{
    SPUserToken token = listWeb.AllUsers[UserId].UserToken;
    using (SPSite site = new SPSite(listWeb.Url, token))
    {
        using (SPWeb web = site.OpenWeb(listWeb.ServerRelativeUrl))
        {
            SPList list = web.Lists[listView.ParentList.ID];
            SPListItem item = list.Items.Add();
            item.Update();
            string formUrl = web.Url + "/" + list.Forms[PAGETYPE.PAGE_EDITFORM].Url
            formUrl = formUrl.Replace(" ", "%20");
            SPUtility.Redirect(formUrl + "?ID=" + item["ID"], SPRedirectFlags.Default, Context);
        }
    }
}
1
  • don't Dispose SPWeb aquired from SPView in webpart. Also when reaquiring SPWeb from another SPUserToken it is faster to make it with listWeb.Site.ID and listWeb.ID.
    – dbardakov
    Commented Mar 31, 2015 at 21:25
1

You need to modify the aspx page with the webpart. Assume its default blog site and page is default.aspx.

  1. Open this page in Sharepoint Designer
  2. Select element with createdby info in "Design view"
  3. Select "Design" tab in List View Tools, then "Customize XSLT", then "Customize Item"
  4. Edit XSL as you wish, Save Page and voilа enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.