ProWorks Blog Rotating Header Image

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!

13 Comments

  1. GREAT ADDITION! how does the blog OWNER come into play in this equation?

  2. hmm… just had a quick play with creating a user that started at the blog node specific to her… the create post dashboard errors at that point…

    i am totally not smart enough to even know where to begin on this one… thoughts?

  3. Jason says:

    Ah, we didn’t have that scenario.

    So is the scenario that you can only post to blogs you own? Or blogs you have permission to see?

  4. the issues is that if i have a user assigned to their specific content node… the dashboard fails… i am looking into various scenarios, etc. and will report back :)

  5. Bill Zipp says:

    MOM Magazine is a client of mine and they are utterly thrilled with your work. Thanks for going the extra mile to address this real challenge. I guarantee there’ll be more MOM blog locations to come.

    GREAT work!!!

  6. Jason says:

    Thanks Bill! We love working with Mom Magazine.

    Bob: I’ll try some things and see if I can repro what you’re seeing. Thanks for testing it out!

  7. Max says:

    I have a very similar requirement to this however my client would like the ability to post to multiple blogs. They will have 3 individual blogs and 1 company blog. When adding an item to their individual blog they want the option to also add the same item to company blog. I could replace your drop down with checkboxes and then update the post logic to do it for every selected item.

    Cheers!

  8. Jason, for testing… set up two blogs… create a user and give that user access to – oh, let’s say the second blog… in the user setup… so, when you login as the restricted user… the blog dashboard errors.

    the blog list dropdown does not populate and the main content area is replaced by a dashboard not found type error.

    i feel like there is code checking to see if the root is != -1 then do some stuff… but i could be just imagining stuff…

    in a perfect world, the blog list dropdown would take into account the blog Admin as well — which is set on the blog homepage tabs.

    let me know your thoughts and thanks for the great additions again!

  9. Jason says:

    Max: I also created a “Blog Reference” type that allow cross-posting. The beauty of it is that the content is shared (one one place to edit) AND the comments are shared (not splitting up comments among 4 posts).

    I’ll try to blog that soon as well and make a whole series of changes.

    Bob: I’ll give that a shot and see if I can fix it. I wondered if that scenario would work…

  10. Jason, any insights on the user dashboard issue i posted above? thanks,

  11. Jason says:

    Not yet, sorry. This week has been super busy. I should have some time this weekend to check it out.

  12. no worries… i have some of that too this week. i tweaked some stuff with the rss feeds to work better with non aspx setups and some site configuration

  13. Jason says:

    Bob,

    Try the mod I did in my latest post here:

    Blog 4 Umbraco Modification Part 2: Multiple Blog Posting From the Dashboard With Umbraco User Permissions

    Let me know if that fixes things a bit.

Leave a Reply