Simulating two Habari blogs with one install (on the same domain)

Now that I have Habari installed, I have been thinking about how I want to lay out my site. I decided that I want to maintain a development blog, but that I would probably also want to have a personal/family blog at some point, and that those should remain separate. My family doesn’t care about my opinions on the latest version of Python, and those who might be interested in my thoughts re: Python don’t want to hear about what my (hypothetical) kids did on our last family vacation.

However, I would like to use the same admin interface and the same Habari install, so I don’t have to maintain the same sets of plugins and custom themes in multiple places. Picky, I know. I don’t see anywhere that indicates Habari would support this specific use case. (Even keeping the admin interfaces separate doesn’t seem to be supported, as note #5 from the multisite page on the wiki states: “Sub-directory sites do not correctly function at the moment. Independent domains and subdomains function very well.”)

After some discussion with the helpful folks on IRC (#habari on irc.freenode.net) and a lot of poking around on the Habari wiki I came up with a plan. Caveat: I don’t actually know very much about how Habari works yet, so it may be that there are parts of this plan that aren’t possible or need tweaking. But it sounds plausible.

A comment from IRC pointed me towards Habari Asides, which I had seen referenced in a couple themes, and suggested that I could use Asides to post different kinds of posts. However, when I looked at the wiki page, I saw that there is nothing technically different about Asides than normal posts - code that handles them just looks for a particular tag and includes or excludes them as needed.

Example from the wiki to exclude a particular tag:

public function act_display(
            $paramarray= array( 'user_filters'=> array() ) )
{
        $paramarray['user_filters']['not:tag']= 'aside';
        parent::act_display( $paramarray  );
}



Example from the wiki to extract just posts with a particular tag:

$this->assign( 'asides', Posts::get( array( 'tag'=>'aside', 
                                                     'limit'=>5) ) );
parent::add_template_vars();

Update:
For Habari .7 and later, you need to use the new taxonomy syntax, like this:

$this->assign( 'asides', Posts::get( array( 
             'vocabulary'=>array('tags:term' => 'life'), 
             'limit'=>5) ) );
parent::add_template_vars();



This is great, and super simple. I should be able to create two pages on my site, one which acts like a home page for a personal blog and one that acts like a development blog home page, simply by excluding tags that I don’t want to see (or only showing posts with the particular tag I want to see). I just have to make sure that every post is tagged for either one blog or the other one.

I also think that I could make the tagging requirement a little more invisible, so that I don’t have to remember to tag each post every time. I could create a plugin that provides me with additional Publish buttons, ‘Publish to Life’ and ‘Publish to Dev’ (or something). When I click these, it would automatically assign the appropriate tag to the post and publish it.

Steps:
- Create the custom theme that makes my home page mostly static and two different pages that each look like a normal blog landing page.
- Exclude the appropriate tags from each blog page.
- Create a plugin that gives me a Publish button for each blog.

I think this should work. I’ll tackle the plugin first, as I think it will be easier and will get me started messing around with 'pluggables' in Habari.

UPDATE: The plugin works now, and here's how it came about.

Tagged: and

 

No one has commented yet. Be the first!