Export A Single Category From MT?
July 28, 2004 |
11 Comments
UPDATE: Tom Werner created a fairly simple solution for this and saved me hours of work. This is what I love about our community! Tom, I owe you a beer! At least.
I’ve got a sticky problem that I can’t seem to find an answer for so I figured I’d post about it here and see if anyone has a solution.
What I want to do is export a single category from a Movable Type blog. Not the whole blog. Just all of the entries from one category. Is this even possible without a using the backend?
I know this could be done via MySQL but in this case I don’t have access to any of that. So a “front-end” solution is needed.
I can’t imagine there isn’t anyone out there who hasn’t wanted to do this before, but I just can’t seem to figure it out or find a solution. Any help would be greatly appreciated.
Filed under: Web Development
Comments
1. Tom Werner said:
Are you adverse to using MT’s export function to generate a text file of every entry and then running a script on that to strip out unwanted category entries? That would certainly be possible.
I bet a line or two of code change to the file that does the exporting could also fix the problem.
Posted on July 28, 2004 02:14 PM | #
2. Mike Steinbaugh said:
Unfortunately, there is no easy way to do this from MT’s admin panel. This was one thing I was hoping they would fix in the 3.0 release.
I think the fastest way to do it is to copy your mySQL database and install a 2nd identical copy of MT. Then go to the categories manager and delete all categories except the category you want to export. Then open up the entry power editor and delete all the entries from your blog that don’t match the category. Once you have done that, simply use the export entries button.
This is a pain but I can’t think of a faster way to do it that doesn’t involve a lot of SQL database manipulation.
Posted on July 28, 2004 02:59 PM | #
3. Keith said:
Mike – Well if I could go into mySQL I imagine I could just export that data from there. Another thing you mention, deleting the entries. Do you know something I don’t? Wouldn’t you have to click the little box for every entry? Seems like a lot of work. Is there a way to mass delete a bunch of entries in a certain category or something like that?
Posted on July 28, 2004 03:25 PM | #
4. Tom Werner said:
Ok Keith, I did some digging in the MT code and came up with a way to do this with only a few lines of code changed in one MT file. I wrote it up on my site, so feel free to wander over and check it out.
Posted on July 28, 2004 03:40 PM | #
5. Anil Dash said:
Probably the simplest thing to do to export is use the default Atom template and tell it to only export from one category.
This template: http://www.movabletype.org/default_templates.shtml#atom_index
Just needs to be modified so that where it says <MTEntries lastn=”1”> you change it to say <MTEntries category=”category name”>
Let me know if that doesn’t make sense. :)
Posted on July 28, 2004 04:19 PM | #
6. Keith said:
Anil – and then that atom template can be used to import into another install of MT? That would seem to make sense as well, but I didn’t know you could do that with the atom template.
If this is true and seeing as how I spent hours searching on this it might be something worth putting into a knowledge base (or into the CMS) somewhere.
Posted on July 28, 2004 04:31 PM | #
7. Anil Dash said:
It’ll be in the KB shortly, and you can submit a help ticket on MT.org for help as well. You’re right, though, this info’s too hard to find right now, and we’re working on making that easier.
Posted on July 28, 2004 05:50 PM | #
8. jim said:
an easier way is to create a category archive template using the format of the MT export file … also remember to set the naming convention and you should have the individual category export data.
Posted on July 28, 2004 08:21 PM | #
9. e.e. cummings said:
If they give you ruled paper, write the other way.
Posted on July 30, 2004 02:58 AM | #
10. Shelley said:
You can download this export text file from our resources site. Paste it into a new index template, and then surround the template code with the appropriate MTEntries tags:
<MTEntries category="yourcatname">
…
</MTEntries>
Set the output file name to yourcatname.txt, then save. Rebuild the template to generate the export file on your server.
(The text file I linked to above is the export format from version 3.0; for 2.661, you can grab the code from lib/MT/App/CMS.pm beginning at about line 2959.)
Posted on August 4, 2004 11:15 PM | #
11. Keith said:
Shelly – Thanks, I’ll give that a shot. Turns out this was a good post because I found out today I need to do a whole lot of this!
Posted on August 18, 2004 12:09 PM | #
Comments are now closed