Using files for page templates in Textpattern

07 Jul 2010

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).

  1. Enable ‘Allow PHP in pages?’ in Advanced Preferences if you haven’t already
  2. Set up your sections and corresponding page templates as you want them
  3. Copy and paste everything in your page template into a php file (such as ‘template.php’)
  4. Create a ‘pages’ folder in your textpattern directory and save the file there
  5. 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!

Recent Posts

Differences between Icon and Logo Design on This is HCD Podcast

10 Apr 2018

Twelve South PencilSnap

01 Apr 2018

The Infinite Canvas

09 Feb 2018

Blade Runner 2049

14 Oct 2017

iPad Pro Pencil loop

11 Oct 2017

Troika #32: Tearjerker

04 Oct 2017

Instagram Hickstagram

  • 18 Apr 2018

    Kind of them to notice!

  • 18 Apr 2018

    A very Happy 20th Anniversary to @hicksleigh! I love you more than ever wifey, and still thank my lucky stars that we met. 😘😍

  • 16 Apr 2018

    If anyone’s interested in buying a nice carbon road bike, I’m selling my Colnago 😉 https://www.ebay.co.uk/itm/Colnago-CLX-3-0-2012-carbon-road-bike-size-54/302705911235

  • 15 Apr 2018

    So pretty!

  • 13 Apr 2018

    Tasty one this

  • 10 Apr 2018

    Replacing worn out MacBook keys. I obviously type ‘a’ a lot

  • 08 Apr 2018

    Grown up Fanta

  • 07 Apr 2018

    Reader, I dropped it. #pintofhead

  • 05 Apr 2018

    THE DOOR OF THE TURIN SHROUD

  • 04 Apr 2018

Contact us

Call Jon on +44 (0)7917 391536, email or tweet @hicksdesign.

Alternatively, pop in for tea and cake at the studio…

Hicks
Wenrisc House
Meadow Court
Witney, OX28 6ER
United Kingdom