Blog 4 Umbraco Modification: Allow Posting To Multiple Blogs From The Dashboard

Umbraco Developer TutorialWe recently had a project for a client, MOM Magazine, that had the need to have several blogs on their site running independently, yet in the same CMS. Blog 4 Umbraco to the rescue! After the Christmas upgrade sprint from the Umbraco team I knew that the blog could handle everything they needed from their existing blog platform, WordPress, and it could handle the multiple blog requirement.

The only bummer after getting the blogs and site set up was that the new cool blogging dashboard page didn't support multiple blogs. It would just blog to the first blog it found.

What I wanted was something like this:

multiple_blogs_1

Unfortunately, the current blog package just looks for the first blog it can find in the content tree and posts to it. So I downloaded the source code and started poking around to see if I could make blog selection happen.

The key control was the CreatePost.ascx control.

First, lets get a ComboBox to select the parent blog to post to...

In CreatePost.ascx add these lines at the top of the "blogpostCreator" panel:

Now to hook up the control we go to the code behind. There is a method called SetBlogRoot() that controls where the blog is posted to. Its call OnInit() and on createPost_Click(). We can leverage the call in the init code to build the list of blogs in the new ComboBox / DropDownList we just added to the front-end. To fill the DropDownList in SetBlogRoot() simply add the "text" column to the list of fields returned in the SQL at the top, create a while loop and fill the new control we created, and select the initial blog to show (the first one). Here's the code:

One more edit to createPost_Click() and were done. Comment out the SetBlogRoot() function call and the line below to get the blog ID selected from the ComboBox / DropDownList.

 

Build and copy over the new DLL to the bin directory and the new CreatePost.ascx to the usercontrols directory and you're ready to rock!

I'll submit this as a patch soon with another modification to allow future and past published dates (watch for another blog in the coming weeks!)

Thanks, and any questions add to the comments below!

Author

Jason Prothero

comments powered by Disqus
back to top