Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2007-08-06 08:48:59
- saccade
- Plugin Author
- From: Neubeuern, Germany
- Registered: 2004-11-05
- Posts: 521
require_once
I’m trying to put some existing php-code into a plugin to use it within my txp-pages.
There is a part of the code in a separate php-file which is called by “require_once” at the beginning of the page.
As far as I understand this means that the code isn’t processed every time the page loads/refreshs, but only once.
Now I cannot figure out how to include this in my plugin-code:
Will the plugin itself be loaded only once and so the code should be simply placed at the beginning of the plugin?
Or should I make a library-plugin and use require_plugin?
Or is there any other way to achieve a “require_once”?
Or should I include php-code in a completely other way (using forms?)?
I’m not a real php-coder but I try to chime in, I hope it’s not a too stupid question and anyone could lead me in the correct direction?
Thanyk you for any help!
Offline
Re: require_once
require_once just ensures that it will be loaded once for each time you load/refresh the page instead of multiple times (which could cause errors due to duplicate defined code). If you used require_once multiple times in your code (by accident), it ensure that the code will still be loaded just once, because it remembers that it was already included after the first time.
The plugin will also be loaded each time you load/refresh the page.
If the code you include/require from the separate file is only used by your plugin and not too big (max plugin code size is 64kB), you might as well include it directly in the plugin.
Last edited by ruud (2007-08-06 10:28:22)
Offline
#3 2007-08-06 10:16:35
- saccade
- Plugin Author
- From: Neubeuern, Germany
- Registered: 2004-11-05
- Posts: 521
Re: require_once
Thank you! So I will try including it directly.
Thanks for your help!
Offline
Pages: 1