One of Textpattern’s drawbacks has always been that page templates are saved in the database. Editing them means using the textarea in the TXP admin interface, but I’m sure most people would prefer to use their favourite text editor.
Here’s a workaround that works in TXP 4.2.0 (I haven’t tried other versions).
- Enable ‘Allow PHP in pages?’ in Advanced Preferences if you haven’t already
- Set up your sections and corresponding page templates as you want them
- Copy and paste everything in your page template into a php file (such as ‘template.php’)
- Create a ‘pages’ folder in your textpattern directory and save the file there
- Replace the content of your page template in TXP admin with:
<txp:php>echo parse(file_get_contents(txpath.'/pages/template.php'));</txp:php>
From there on in, you can edit the php file. There may be a performance hit doing this, but all TXP tags work. Much easier!
I’m using cnk_versioning for this purpose which is a way more elegant solution, imho.
@Marcus – care to write about your method and submit to TXP Tips?
@Jonathan – when I’ll find the time, I’ll get back to you. Till then, keep on the good work with TXP Tips! :-)
I followed their initial conversation on twitter and Sam Brown suggested this one:
<txp:php>include(txpath.’/pages/default.php’);</txp:php>
Jon updated his post, but now I see he has removed that one. Any idea why?
@Filipe: It was Robert’s (wet) recommendation to do so. And a follow up tweet.
Am I wrong when my first take on this is: modules could be treated as such?
I so hoped that this would be a plugin-free easy solution, just to find out that it doesn’t work with the Multi-Language-Plugin (MLP).
If you use the MLP to localise text within templates via ##localised_text## tags, those will stop switching languages and are displayed straight as tags with the double hashes…. :-(
I use the cnk_versioning PlugIn to edit my templates with the Eclipse IDE and to use the TXP Tags with the Eclipse Code suggestion. I started to add the TXP Tags in the Eclipse Templates. So when i start typing <txp:… i get a list to choose from. I still need to add a bunch of TXP Tags to the templates but if anyone wants the XML file to import to Eclipse i would gladly share them with the community.
Screenshot from Eclipse
@superfly: Oh yes, please share. I’m currently using JEdit but having txp tag completion/suggestion is worth the switch.
Well. I am looking for an elegant fail safe way of working with external Pages and Forms.
the warning that comes with cnk_versioning leaves me cold! I have no confidence is using it.
“Please use this with care! Your pages/forms/css will be deleted from the database, when you delete the corresponding files.”
Two questions: what is Eclipse IDE? Where do i get it.
and is the cnk_versioning a safe choice given this warning:
“ Please use this with care! Your pages/forms/css will be deleted from the database, when you delete the corresponding files”
PS i just thought of a solution: one could have a mirrored back-up of the external _templates directory.