Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Txp Plugin Template for Developers
Both of the templates (Dean’s and Zem’s) could use a
header(‘Content-type: text/plain’);
line before the echo line.
This will make it so that browsers treat the code as text and display it, rather than treating it as source and not. Easier cut and paste.
Offline
Re: Txp Plugin Template for Developers
Example:
Instead of this:
<pre>
$plugin[‘code’] = <<<eod
function xxx_myplugin($atts) {
}
eod;
</pre>
write this:
<pre>
$plugin[‘code’] = <<<eod
function xxx_myplugin(\$atts) { // <= notice the \ char !
}
eod;
</pre>
I don’t know if this is already known — it just took me more than an hour to figure this out, so I thought maybe others encounter the same behaviour.
Great!!!! Thank you!!! :)
Offline
#27 2005-01-19 23:25:05
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: Txp Plugin Template for Developers
There’s a new version of zem_tpl available here.
This one separates the template from the “compiler”, and produces plugins in the 1.0 format.
Alex
Offline
Re: Txp Plugin Template for Developers
I am not sure if there is already a forum/thread(s) where developers can exchange information, so I’ll just write it here:
It speeds up development tremendously if you do the following:
1. Use zem’s tamplate.
2. edit admin_config.php and in the array add: <b><notextile>‘plugin_cache_dir’ => ‘/full/path/www/textpattern/myplugins’,</notextile></b>
3. create a directory /full/path/www/textpattern/myplugins [edit: changed path to be different from tmp]
4. drop your plugins (uncompiled) in that directory (make sure plugin name and plugin-filename correspond, e.g. zem_test should be in zem_test.php)
(Note: do not put zem_tpl.php in the same directory)
Now during development you can skip the compile, upload, activate steps (and you’re not confined to editing in the admin-panel or copy&paste). Simply edit the file in the tmp dir, it will be included on each run.
Thanks to zem for the tip. :)
Last edited by Sencer (2005-05-25 09:44:57)
Offline
Re: Txp Plugin Template for Developers
Excellent tip. I had always just pasted my code into taghandlers.php while I was working on it.
Will this work with admin side code as well? I don’t seem to be able to get my admin side code to execute although my regular plugin code works fine on the external site.
Offline
Re: Txp Plugin Template for Developers
Oops, my bad. You have to enter the full (not the relative) path to the directory in admin_config. I’ll update my above post.
Actually with the cache directory, txp will always include your plugin backside, and frontside. So with admin-side plugins you have to remember to set $plugin[‘type’] to 1 before distributing (you may forget it, but it would still work for you, but not other people).
Offline
#31 2005-05-24 22:57:19
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Txp Plugin Template for Developers
Awesome!
Offline
#32 2005-05-25 01:58:39
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Txp Plugin Template for Developers
Okay, I must have missed a step or done something stupid.
Try and view my (dev) Txp site – either public or admin, and all I see is my base64-ed plugin string. Any ideas?
Offline
Re: Txp Plugin Template for Developers
Mary – don’t put zem_tpl in the directory with your plugin. I did the same thing at first.
Offline
#34 2005-05-25 03:04:07
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Txp Plugin Template for Developers
Ah okay. Thanks! Of late Firefox has been acting weird when compiling the plugin, so it was taking forever going back and forth. Now I can be in plugin-making bliss. :)
Offline
Re: Txp Plugin Template for Developers
Sweetness. It was the relative path that was causing me a problem. Switched to absolute and it working fine now, front end and admin plugins.
Also, FYI, its not totally necessary for the filename to be the same as long as you uncomment the line that reads
<code>$plugin[‘name’] = ‘your_plugin_name’;</code>
and set the proper plugin name.
Last edited by wilshire (2005-05-25 16:14:50)
Offline
#36 2005-05-25 19:12:32
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Txp Plugin Template for Developers
Yep, that’s what I did, adjusted zem’s template to add that field and also the type (admin) option – better to do it from the start or else I’d forget it altogether.
I’m so hyper. This has allowed me to do some real work on a plugin, without wasting my time fiddling around. Muchas gracias, Alex and Sencer!
Offline