Multiple Category Support in Textpattern

Update: The rss_unlimited_categories plugin has been released.

For a project that I’m currently working on, I had the need to assign articles to more than one category. The site being developed is actually an e-commerce site so that articles in this case are products. Most products can be categorized into several different groups so that users can easily find what they’re looking for.

Why Textpattern?

I knew I wanted to use Textpattern to develop the site but support more than two categories was going to be a show stopper. Without it, there just wouldn’t be a way to effectively organize the products on the site. So why would I want to use Textpattern knowing this? Simply put, the work of adding multiple category (or tagging as some call it) support was little compared to the headache learning how to use another CMS or e-commerce package to build the site.

There are also some benefits to using Textpattern for an e-commerce site in general. From my clients perspective, the admin interface is easy to understand and use. From an SEO perspective, the ability to easily generate clean URLs are a great advantage, especially for e-commerce sites. And from my perspective, my familiarity with Textpattern should make up for the time spent adding multiple category support.

Changes to the Database

Adding support for multiple categories first required adding data storage. I created a new table that simply maps an article ID to a category ID. This will allow for as many categories as necessary to be assigned to a single article.

Changes to the Write Tab

Multiple Category Select in Textpattern The first change necessary was to add a multi-select list to the write tab. This seemed like the most natural choice to fit into the current layout. Simply hold Ctrl+click to select as many categories as you’d like. I also modified the article list tab to display the multiple categories instead of just the standard two.

Public Side Changes

In order to use my new categories I created a new public side tag that mimicks the function of the standard article_custom tag. The difference is that the category search is executed on my new table instead of the Category1 and Category2 columns in the textpattern table.

Plugin Possibilities

As I have it now, this is just a mod to the Textpattern 4.0.1 codebase. Could it be a plugin? Sure, I suppose it could. At this point I chose to make my changes directly to the article and list pages rather than mess with javascipt/DOM manipulation to add the new elements to the screen.

Depending on the interest I’ll look to publish this as either a mod that people can perform on their own or as a fully packaged plugin. I’ve read of people asking for “tagging” support recently so if anyone has thoughts on this, fire away!

Comments

22. September 2005

awesome!
interested in fully pluginized multiple-category support, and also in tagging. could use them both in conjunction? or are you thinking one would eat the other?

22. September 2005

Marvelous!

23. September 2005

you are like a txp god.

plugin asided, i would dig just knowing the mods you made to the code.

Jerry

23. September 2005

Great work . . . at the very least I would like to see this integrated as a plugin, so that other than db table creation, this has less chance of disrupting the default TXP install.

I would encourage you to approach the TXP development team to see if they can’t get this rolled into the core TXP code base. Right now the lack of multi-category support is a great weakness in a great CMS.

Matt Helmick

23. September 2005

I’d definitely be interested in this for an upcoming project of mine. I hope it’s released soon.

24. September 2005

I would encourage you to approach the TXP development team to see if they can’t get this rolled into the core TXP code base. Right now the lack of multi-category support is a great weakness in a great CMS.

I second this.

you are like a txp god.

second this too :)

25. September 2005

Oh my, I would die to have this!

You are indeed a TxP god…

26. September 2005

It would be really good if this (or something better) would be in article form in standard version because it’s currectly too limited when compared with, for example, WordPress. I like the way Textpattern has made using things easier than in many other web CMS software, but better support for multiple categories really should be standard feature. Simplicity is good as long system still has enough power to do things without need for too many hacks.

27. September 2005

I too am very interested in this. Thanks for your amazing work!

28. September 2005

Interested! :)

Paolo

2. October 2005

Pluging first, core second. It’ll take ages to get into the core. This is great news for patteners, well done.

Lee

4. October 2005

At the University of Glamorgan we use tags to build relationships between articles.

We have a plug-in that does it. I shall have to ask the writer of said plug-in if he will open it up.

We’ve now built a pretty big site in Textpattern,but there are still loads of things to do.

4. October 2005

Wow! Great! I couldn’t imagine before what’s possible with txp.

6. October 2005

Wow. I think this could be really useful. The only thing is that lots of plugins that refer to categories (article tags, suparchive, if_category) probably wouldn’t work out of the box. But maybe they would if it would be rolled into the TXP core…

6. October 2005

A brilliant idea! It would make sense to have this kind of functionality in the core rather than as a plugin. The method of multiple categories you illustrate is used in Symphony21 and works very well. It’s certainly intuitive. Of course this method doesn’t show the category hierarchy but maybe we actually don’t need it! Flat categories (or content tagging) alongside sections and subsections ability would be great.

6. October 2005

+1

A long awaited feature in the txp community, a much discussed feature request made true by the great Rob !

Can’t wait to test this :-)

11. October 2005

I’d say core first, no plugin. Why? Because the longer we have only 2 categories, the more arriving tags and plugins will depend upon it. Yucky. Make it a patch and send it to the devs, offer a mod to everyone else (if you feel like it).

14. October 2005

I would say mod. I can only imagine the backbone work to export this out as a plug in. The DOM work alone would be very time consuming. The need to get this in the core is pretty imperative, but for now a plug in would create a lot of future problems both from a support point of view and when it does make it into a core feature (crossing fingers) then everyone who is using the plug will have a ton of work porting all of that information over to a new format.

Jamie

Jamie

14. October 2005

to quote veruca salt, “i don’t care how. i want it now!”

Jerry

27. October 2005

Damn. I’m interest, i’m interest!!!
x)

All my support from the spanish comunity.

(By the way, thanks foe the hard work)

4. November 2005

When the suggestion of doing so makes 3 people call you a deity, i think there’s some small level of interest ;-) Add me to the list! As long as rss_suparchive supports excluding categories with it, this would be awesome.

Boblet

4. November 2005

Very true Boblet. Looks like there’s some interest after all. Here’s a few updates…

The topic was discussed on the TXP Dev mailing list and I think the best option now is a plugin. The dev team understandably doesn’t want to introduce large changes into TXP that could potentially destabilize it.

You might have seen on the Forum that the site I developed this for is now online. You can check it out: Favorable Designs.

Check the Forum in the Let’s See Yours section for more details. I’d post a link but I’m attempting to post this from my cell phone on an airplane so I just hope it works.

Rob

5. December 2005

Hey guys! I just finished writing a TXP plugin that will allow you to use tags on tour TXP blog.

Throw your categories away! With this nifty plugin for TXP you can now start tagging your thoughts. Just install and start tagging away…

Get the plugin here:
http://aroussi.com/article/45/tagging-textpattern

Cheers!

7. January 2006

Having come from MT, and in the business of showing my photography, assigning multiple categories would definitely be used by me. I found this page in an attempt to solve this very issue. So a plug in would be fantastic.

21. January 2006

As announced here the rss_unlimited_categories has been released.

Rob

Commenting is closed for this article.

Textpattern Solutions

Textpattern Solutions

Textpattern Solutions is the first book published on Textpattern.

details at friends of ED or the official book website.

buy it at amazon.com