Textpattern tips, tutorials and code snippets

Multiple blogs

On a recent project, we needed to create multiple blogs for a site. Since Textpattern does not support multiple weblogs, this might seem a difficult task.

After some time thinking how to achieve this with Textpattern, here is the solution I used for this project. The results may be seen here.

  1. Download and install the ob1_pagination plugin.

Make a blog front page

Create a section called blogfrontpage. Settings: Selected by default=no, On front page=no, Syndicate=yes, Include in site search=yes. Adjust according to your needs.

Create your blogs using sections

Our blogs will be sections. Create new sections to host your blogs. In our example, create two new sections – newsblog and personalblog. Same settings as above.

Create a page template for your blogs

In this case, it worked best to have a separate page for the blogs. Create a new page called blogs and save. You can copy your default page then adjust the content of the page later.

Here is the code for our blogs page example:

<txp:if_section name="blogfrontpage">
<txp:if_individual_article>
<txp:article limit="1" form="blog_article_single" />
<txp:else/>
<h2>My blog front page</h2>
<txp:article_custom limit="10" section="newsblog,personalblog" form="blog_article_list" />
</txp:if_individual_article>
</txp:if_section>
<txp:if_section name="newsblog, personalblog">
<txp:if_individual_article>
<txp:article limit="1" form="blog_article_single" />
<txp:else/>
<h2><txp:section title="1" /></h2>
<txp:article limit="10" form="blog_article_list" />
<txp:ob1_pagination firsttext="First" previoustext="&laquo; Previous" nexttext="Next &raquo;" lasttext="Last" ulclass="pagination" />
</txp:if_individual_article>
</txp:if_section>

blog_article_list form

<div class="blogpost">
<h3><txp:permlink><txp:title /></txp:permlink></h3>
<p class="postdate"><txp:posted /></p>
<txp:excerpt />
</div>

blog_article_single form

<h3><txp:title /></h3>
<p class="postdate"><txp:posted /></p>
<txp:body />

And that’s it. A simple multiple blog site with a blog front page and a nice URL structure. Check out the final site to see how it works. The drop down menu shows the individual blogs.

Note: The final code for the site differs slightly from the above, and has been stripped down for simplicity.

3 Comments Comment feed

Since Textpattern does not support multiple weblogs…

This is a great tip, but why would you say that? There may not be a button you can click in the back labeled “Create a New Blog,” but as you have demonstrated, it just takes a few simple design decisions to get the functionality you want.

I’d be interested in seeing a tutorial premised on “Since Textpattern does not support forums…”

Hi John, you are quite correct that with TXP it is relatively simple to create the impression of a multiple weblog. However, true multiple weblogs are separate entities. See this TXP FAQ post. Alex’s description of multiple weblogs is what I was referring to.

Thanks! That makes sense.

Add a comment

Use Textile help to style your comments