Custom BlogAdminWebPart

 

I needed to host the OOB BlogAdminWebPart (the one that shows "Manage Posts" and other blog administration options) outside the context of a blog site. Problem is, BlogAdminWebPart's links' URL's cannot be configured to point to an arbitrary place.

Too bad - ended up creating a custom one; code below. It needs a property to point to the blog site to build those URL's, but core is there.

public class CustomBlogAdmin : WebPart
{
    protected override void CreateChildControls()
    {
        string js = @"<script type=""text/javascript"">
                function newPost() {
                var options = SP.UI.$create_DialogOptions();
                options.width = 500;
                options.height = 250;
                options.url = ""https://server/sites/blogs/user/Lists/Posts/NewPost.aspx?Source=/sites/blogs/user/&IsDlg=1"";
                SP.UI.ModalDialog.showModalDialog(options);}</script>";

        Controls.Add(new LiteralControl { Text = js });
        Controls.Add(new LiteralControl { Text = "<a href=\"https://server/sites/blogs/user/Lists/Posts/\">Manage posts</a><br>" });
        Controls.Add(new LiteralControl { Text = "<a href=\"https://server/sites/blogs/user/Lists/Comments/\">Manage comments</a><br>" });
        Controls.Add(new LiteralControl { Text = "<a href=\"javascript:newPost()\">New Post</a><br>" });
    }
}