Hacking Textpattern to use raw files for the design
This isn’t really so much a hack, I just didn’t know what else to call it. It’s more like just using the resources available to get a different behavior from Textpattern. The primary reason I switched back to Wordpress was because when my site went down, I couldn’t access any of my template information. The markup, most of the CSS, etc. was all housed in the database, and encrypted apparently, so I couldn’t even go into the database to get it.
So I’ve figured out a way around that, and maybe it’s not the best way, but it works. Definitely tell me if there’s a flaw to doing things this way. When I say it “works” I just mean I personally haven’t noticed any problems, but there may be some I don’t know about.
CSS Styles
The first thing I did the first time I lost CSS information in Textpattern was use “importto pull in a raw CSS file. I also prefer to use [Textmate][] to code, so this was a real treat instead of doing everything in atextarea` in the TXP admin area.
Inside the styles area, I create stylesheets as usual, attached to whichever sections I need them to be, and then in the style area, I import them: “import url(/css/style.php);`
You could also link them directly from the header area, but then you’d have to use <txp:if_section> to get it to work the same way.
Pages & Forms
To get markup into raw files is a little more tricky because you use a PHP include and PHP in TXP is a little tricky.
- First, I make sureAllow Raw PHP* is turned OFF andAllow PHP in Pages* is ON.
- Next, I create my raw files (txt, html, php, whatever) and put my TXP code in them just as I would in the admin fields.
- I create folders for pages and forms too, so I can keep them separate.
- These folders are in a parent folder called site_design, inside the textpattern directory. That way you can use
txpathin a minute.
- Then, I set up my include using Textpattern’s code for PHP.
<txp:php>
include(txpath.'/site_design/pages/section.php');
</txp:php>
Now I can use TXP tags from these “remote” files instead of keeping everything in the database and accessing it only from the TXP admin area. I just wish I’d figured out this last part before I switched to Wordpress because I would have stayed with Textpattern!
Note: I don’t put all the forms in include files because there are so many of them, and many times they don’t have much in them, so I usually just do forms which tend to have a lot of code in them, like the header, footer and sidebar includes.
Share Tweet me (but don't mistweet me)
Copyright © 2008 – 2010 Natalie Jost




















Kindred
Lovely Clusters
ohbrooke
Simple Blueprint
Crochet Pennants
Chocolate Pancakes
Tortilla Chips!
A Winter Scene
Fabric Book Covers
Make a Shirt into a Pillow
Vintage Popcorn Boxes
Paper Bags
Patterns
Using Filter Masks
7 Comments
Hi… Nice articles… It’s help me to build website with textpattern…
Thank you for the ideas! However, for the static css files there is a solution: rvm_css plugin. You can use the admin interface to make changes in your css files, and it generates the css files in a folder on your server. That’s all – quite comfortable.
Thanks, Zoltan, I’m sure that will be helpful to someone. For me, it’s a lot easier to add
@importfor the CSS and easier/safer/cleaner to do everything I can before turning to plugins to do the job.I’m not against plugins at all when there’s no other way. I would just much rather have control of my site and what code is running it, whenever possible. Although most plugin developers are not malicious, I like to be on the safe side and not use them at all if there’s a way to do something without.
Trying to revisit this page and got this error:
A few weeks ago I found the WP Plug-Ins “Advanced Permalinks” which can handle redirects if you change your whole permalink structure, and “Redirection” which will automatically handle redirection if you change the post slug of an article. Both from http://urbangiraffe.com/
I use hcg_templates to manage my css, forms, and pages. this allows me to edit in my favorite editor, upload, and sync.
You could also use the “Edit in TextMate” bundle (ctrl+cmd+e) or “It’s All Text!” in Firefox, both of which are a lot simpler.
I have done two things that are very simple:
In my template i link to a hard coded css file
<link rel="stylesheet" type="text/css" media="all" href="/c/mystyles.css" />In the Stle tab in admn interface use an import
@import url(/c/mystyles.css);Either is fine although the first one LINK is more supported… still all major browsers support
@importnowadaysI use #1 but at the same time I still always include the style from admin in my templates if I ever need to change styles and I don’t have ftp access.