Services Products About Us Case Studies Clients
Modern Signal
Modern Signal Home Page
Lighthouse on beach About Us
Offering a full range of development services: strategy, design, application programming, database development
News & Recents Projects
Setting Up Multiple MangoBlog Instances with Shared Code and Database

MangoBlog is a sweet (ha ha) ColdFusion-based blog, but it doesn't currently support creating multiple blogs using the same codebase.  You can easily make a copy of the code and create another blog that way, but if you're looking at 3, 4, or more blogs, then it's going to start getting out of hand, especially if you want to share the same basic styles for all of the blogs.  (Styles can change, of course!)

One thing that I didn't hear suggested on the MangoBlog forums was to simply create a virtual directory on the webserver in order to create another blog using the same code as an existing blog, and that turned out to work really well.  I wanted to document the steps I took to set that up for the benefit of my future self and others.

Set up Application.cfc

The first thing is to set up Application.cfc to support multiple blogs.  At the top of Application.cfc I added this (my first blog was in a directory called "blog" and all the new ones are in other subdirectories):

this.blogid = ListFirst(cgi.SCRIPT_NAME,"/");
if (this.blogid is "blog"){
    this.blogid = "default";
}

Then I included the blogid in the application name:

this.name = "mango_#right(hash(GetDirectoryFromPath(GetCurrentTemplatePath())),50)#_#this.blogid#_v1_4_2";

Then I used that blogID in the OnApplicationStart:

<cfset facade.setMango(createobject("component",variables.componentsPath & "Mango").init(getDirectoryFromPath(GetCurrentTemplatePath()) & "config.cfm",      
    this.blogid,
    getDirectoryFromPath(getCurrentTemplatePath()))) />

With that initial setup, creating a new blog is a 3 step process:

1. Create new blog and blog author records, copying settings from the default blog

The sql below is what I used

DECLARE @blogid nvarchar(32),@basePath nvarchar(32)
SET @blogid = N'new_blog_subdirectory'
SET @basepath = N'/' + @blogid + N'/'

INSERT INTO BLOG_blog (id, title, description, tagline, skin, url, charset, basePath, plugins, systemplugins)
SELECT @blogid, title, description, tagline, skin, replace(url,'/blog/',@basepath), charset, @basePath, plugins, systemplugins
FROM BLOG_blog
WHERE ID = 'default'

INSERT INTO BLOG_author_blog (author_id,blog_id,role)
SELECT author_id,@blogid,role
FROM BLOG_author_blog
WHERE blog_id = 'default' and role = 'administrator'

2. Copy the blog settings in config.cfm

Make a complete copy of the node that starts "<node name="default">"  and change "default" to your new blog subdirectory name.  Since the config settings for all of my blogs are the same, it would be nice if I could just tell it to use the default configuration, but that doesn't seem to be possible without changes to the MangoBlog code.

3. Create a virtual directory in IIS

Just point the new directory to your original blog directory.  I assume that you can do the same thing in Apache, but I don't have much experience with that.

That's it!

Comments

Rick's Globally Recognized Avatar Thanks for this post - it's the first explanation I've seen that offers enough detail so that others can actually get it to work. And it's an elegant solution to boot.

I'm curious -- how have you dealt with the implementation of separate styles for multiple blogs that nevertheless share some pieces of code in common with pages elsewhere on the site but outside the blog? In other words, say you want to integrate multiple blogs into an established site and use existing code from it for, e.g., a sitewide navigation bar on the blog pages. I know that I need to create custom themes, but so far anything I've tried to "include" code from outside the blog code directories hasn't worked.

Posted on March 29, 2010 2:26:47 PM EDT by Rick

David Hammond's Globally Recognized Avatar @Rick, if your main site is ColdFusion-based, it should be pretty easy to include styles from the site in your blog(s). For the site I was working on, I took the GlossyBlue skin and made the changes I needed. In my CMS, the templates are all handled by CFCs, so I just needed to instantiate a CFC within the skin files and call functions to include the header and footer. The specifics are going to depend completely on how your site is set up. I'm not sure why including didn't work for you, since the skin files are all .cfm files which should make it easy to include code.

If you need different styles for different blogs, you could create several skin directories and use the BlOG_blog.skin database field to specify the skin for each blog. In my case, I wanted the same style for all the blogs, so this wasn't an issue.

Posted on March 29, 2010 3:05:09 PM EDT by David Hammond

Rick's Globally Recognized Avatar @David, thanks for the reply. I did have the different styles [mapped to] different skin directories [mapped to] entries in the BlOG_blog.skin database column business already figured out. But I'm still a relative novice at complex CFC-based applications, so figuring out exactly what I can do and exactly where in the code I can do it remains a challenge. Anyway, you've given me an idea of something else I can try.

Posted on March 29, 2010 4:25:13 PM EDT by Rick

Leave a Comment
Name (required):
Email (required, will not be displayed):
Website:
Subscribe to this page:

Topics for this page:

August 2010 -- Modern Signal completes integration of new design for Teaching Strategies.com.
July 2010 -- Modern Signal launches new site for the NAHB International Builders'Show, the largest residential building industry tradeshow in the world.
July 2010 -- Modern Signal awarded contract to build a social media plan for The International Manufacturing Technology Show, one of the largest industrial trade shows in the world, with more than 1,100 exhibitors and over 92,000 visitors.
July 2010 -- Modern Signal completes launch of Teaching Strategies GOLD, a brand-new assessment tool with feature-rich tools for teachers, administrators, parents and trainers.
June 28, 2010 -- Modern Signal launches redeveloped website for National Health Policy Forum, a nonpartisan research and public policy organization at The George Washington University. The new site includes admin tools to manage email announcements, event invitations and RSVPs, surveys, and an extensive library of publications and meeting materials. The site also features a customized Google Search integration, and a new content management system was integrated within the existing design and information architecture of the site.   -View-
April 22, 2010 -- Modern Signal launches a redesigned website for The NALP Foundation for Law Career Research and Education, a nonprofit organization that works to ensure that the legal community and society at large have a reliable, objective, and affordable source of information.The site includes a content management system; bookstore; and news, events, leadership, and products tools to manage the featured homepage content. -View-
April 5, 2010 --
A redesigned website is launched for Independent Sector, a nonprofit coalition of approximately 600 charities, foundations, and corporate philanthropy programs, collectively representing tens of thousands of charitable groups in every state across the nation. The site includes a content management system, discussion forum integration (phpBB), blog integration (MangoBlog), collaborative authoring wiki, tool to create surveys, video template, among other features.  -View-