Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-09-15 11:06:19

wosh
Member
Registered: 2005-01-15
Posts: 12

Use files for forms / pages / plugins

Okay, I’ve hacked together a little plugin that allows one to use regular files for forms, pages and plugins.

Right now, it’s pretty ugly. It does work though.
Normally installed plugins continue to work, but forms and pages are only available through files.
It is pretty easy to make TXP try and load the form from a file first, and then fall back on the database if the file doesnt exist,
but I only now think of this, so that’s not implemented yet.

I made this mostly because I am getting sick & tired of having to edit html in a textarea box, while I have a supernice editor with
syntax highlighting, autocompletion and everything else sitting idle on my desktop.

Want to try it out? Read on…

Get the rar file with everything here

This plugin requires 4.01 (since it relies on callbacks on the visitor side for loading plugins).
I suggest you try it out on a clean install.
Unfortunately, since PHP does not support function overloading, we have to edit two core textpattern files.
We are only changing one line in each file though.

File: txplib_misc.php
Go to line 1076 and comment it out. It should look like:
<pre><code>//$f = fetch(‘Form’,‘txp_form’,‘name’,doSlash($name));</code></pre>
Under that, add the replacement. Add this:
<pre><code>$f=fetch_form_file($name);</code></pre>

File: publish.php
Go to line 416 and comment it out. Like so:
<pre><code>//$html = safe_field(‘user_html’,‘txp_page’,“name=’”.doSlash($page).”’”);</pre></code>
Then add this below it:
<pre><code>$html = fetch_page_file($page);</pre></code>

Good. Now open the plugin.txt and copy the contents, go to your plugins page, install it, and then enable it.
Now copy the filetoy folder included in the archive to your textpattern (site/textpattern) folder.
You should be done.

Load up the site’s front page. You should not get any errors. At the top there should be a little “Hello World” (from a ‘plugin’).
All the forms on that page are coming from files.

Anyway, I’d love to get people’s opinion on this. IMHO, textpattern should include something like this out of the box (but with better integration, ofcourse).

cheers,
Bastiaan

Offline

#2 2005-09-15 12:15:49

wosh
Member
Registered: 2005-01-15
Posts: 12

Re: Use files for forms / pages / plugins

Turns out I was a wee bit too fast.

txp:output_form calls the fetch (db) function directly, instead of using the fetch_form method (why?).

So you’ll need to edit that function aswell.

Last edited by wosh (2005-09-15 13:54:37)

Offline

#3 2005-09-15 13:49:03

Manfre
Plugin Author
From: North Carolina
Registered: 2004-05-22
Posts: 588
Website

Re: Use files for forms / pages / plugins

I’ve always gone the cut & paste approach to editing the pages and forms on my site. It saves me from having to log in to the webhost.

Offline

#4 2005-09-15 13:53:55

wosh
Member
Registered: 2005-01-15
Posts: 12

Re: Use files for forms / pages / plugins

Yeah I sometimes do that too, but still, it’s annoying. And as my host supports webDAV, I can simply mount my web folder. Also, many editors include FTP support (skedit comes to mind), and many ftp clients support editing of files in your favourite editor (transmit, …).

I am simply fed up with all the hassle.

Offline

Board footer

Powered by FluxBB