Textpattern is a content management tool for blogs and small websites. It allows site designers to exercise a great deal of control over the layout and functionality of websites through a highly expressive template language modelled on XML markup tags.
One downside of TXP, however, is that the templates are all stored (along with page content and sometimes the CSS file) in the TXP database have to be constructed almost entirely inside TXP’s administration interface:
Now, editing code directly in browser textarea
s isn’t the worst thing in the world, but it’s not a lot better than, say, using Notepad on Windows. At least Notepad lets you use the tab key. And when you have to move a design from site to site, you have to recreate each template page and snippet (reusable snippets of template code are known as “forms” in TXP parlance) one by one.
However, I’m not here to critique TXP’s minor functional limitations. Instead I want to share a small but fairly advanced trick I discovered as I was trying to think of a way to move a fully working and complete design from a TXP install on my localhost up to the install on my production server. And it’s here that TXP’s database-centric template system becomes a significant advantage.
All TXP template pages are stored in a database table called “txp_page”. All TXP forms are stored in a database table called “txp_form”. So potentially, all you need to do to initiate an updated design on a TXP site is to over-write each of those tables in your production MySQL database with two exported tables from your local database.
Easier said than done, right?
Well, unless you’re really comfortable with command line MySQL, you’ll need, at minimum, a working version of PHPMyadmin on your server and some kind of database tool on your development machine. I use Sequel Pro, which makes finding and then exporting the requisite database tables as a “.sql” file very easy. Remember, you have to export each table separately for this to work.
As an aside, a real MySQL pro could probably tell me a much faster way to do what I’m describing. And I hope they do! But I’ve tried this method and it works a charm.
Important note: It should go without saying that you really have to back-up both your local and production database before you attempt this trick. I once lost several weeks worth of posts when I ran a database operation that I shouldn’t have. Though in my defence, it was a dodgy TXP database plugin that I was using AND I thought I was hitting the “run backup button”. Always double-check every action when you’re messing with databases.
So, once you’re in PHPMyadmin, select the first database table you need to update. Choose “import”, select the .SQL file on your local machine, then hit “go”. Once that’s merged into the database, choose the next table, import again, and, whammo-bammo. You’ve got a whole new Textpattern template live, without having to cut and paste into a single textarea
. Pretty neat, huh?