Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Dev help on plugin
I have 2 questions on developing a plugin.
1. I am trying to create an acronym plugin since the only acronym mods out there hack the classtextile.php file, and I think having a straight plugin would be cleaner. Anyway, I think that what I want to do is pull the article body, parse it through the acronym array, and then return the text with the proper <acronym></acronym> tags inserted. I have looked through the plugin developer docs and am stuck on pulling out the body from the global variables. If I understand things correctly, the body text is contained in $thisarticle[‘body’] but I am not sure on how to pull out that global variable in the plugin. Would it be:
global $thisarticle[‘body’]
Is that correct? I have tried that and it does not seem to work. If someone can get me started on pulling out the body text I would be most appreciative. These are the docs I have come across:
http://rise.lewander.com/textpattern/99/txpglobal-variable-thisarticle
http://www.focusontheclouds.com/home/articles/72/accessing-global-variables-in-textpattern
2. As far as creating the plugin itself, I have found Zem’s plugin template and related docs and am using his template. Am I supposed to upload my plugintemplate.php file to /textpattern/tmp and then it should appear in admin>plugins? Or does it not appear but still work? I understand that once it’s final I need to compile it for distribution, but I am a little unclear on whether I just upload my template.php to /tmp and then it should work for my testing purposes or whether I also need to compile it before I can test it.
Thanks very much.
Offline
#2 2005-11-14 04:08:02
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Dev help on plugin
Regarding the plugin creation: follow the instructions Alex provided.
Offline
Re: Dev help on plugin
Mary, thanks, I did see that thread earlier; that’s how I found the zem template etc.
The instructions are still not clear on where to put zem_tmpl.php and where to put the plugin template php. Do I put zem_templ.php in /textpattern/include and then edit the “include” in the plugin php file to point it to /textpattern/include? Or, if I am testing a plugin, do I just upload my plugin php file to /tmp and forget about zem_tmpl.php entirely until I’m ready to compile? Some posts state to not put the zem_tmpl.php in the same directory as the plugin php file but Alex’s instructions don’t specifically state that.
I appreciate any clarification. Thanks!
Offline
Re: Dev help on plugin
I have been able to compile the plugin by copying both my_plugin php file and the zem_tmpl.php file into /textpattern/tmp and then pointing my browser to http://www.example.com/textpattern/tmp/my_plugin.php and then copying the resulting code into the install plugin box. It seems to be working ok. Is this the right way to do it? If so, then why the cautions about uploading zem_tmpl.php into the same directory as my_plugin.php?
Offline
#5 2005-11-14 23:50:57
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Dev help on plugin
create a directory /full/path/dev/plugins
under Advanced Preferences/Admin, set: ‘plugin cache dir’ => ’/full/path/dev/plugins’,
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)
> “The instructions are still not clear on where to put zem_tmpl.php…”
True.
> “…and where to put the plugin template php.”
That they do.
> “Do I put zem_templ.php in /textpattern/include and then edit the “include” in the plugin php file to point it to /textpattern/include?”
No.
> “Or, if I am testing a plugin, do I just upload my plugin php file to /tmp”
No. You could but I wouldn’t advise it.
> “…and forget about zem_tmpl.php entirely until I’m ready to compile?”
Yes.
> “Some posts state to not put the zem_tmpl.php in the same directory as the plugin php file but Alex’s instructions don’t specifically state that.”
Yes, they do.
“…Is this the right way to do it?”
No. Specifically, here are the directions restated, so you can see what I mean by my answers above.
- Create a new directory somewhere outside of your site/Textpattern. It’s name and location doesn’t matter. Move zem_tpl.php into this directory, to be used later.
- Create a new directory. Where it is and what it is named doesn’t matter. To keep it simple, create a folder named “plugins” inside the “textpattern” folder.
- Login to Txp and browse to admin > preferences > Advanced Preferences.
- Copy the value for the “tmp” folder location, and paste it into “plugin_cache_dir” (this string apparently hasn’t been translated yet, hence the underscores).
- Replace the “tmp” part of the path with “plugins”.
- Place your plugin script inside the “plugins” directory. It will now be loaded by Textpattern, as if it was installed.
- Once you’re finished, move your plugin into the folder where you have zem_tpl.php. Load your plugin, and it is compiled for you.
Clear as mud, right? :)
Offline
Re: Dev help on plugin
Cheers, Mary! Thanks so much for that concise write-up. I think I get it now! :)
Thank you again for taking the time. Your explanation is a huge help.
Offline
Pages: 1