Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Standard location for plugin support files
Hi Nils,
in your stylesheets you would use
http://example.com/index.php?abc_myfile=myimage.gif
as the url for your image.
In the plugin-code you would do:
<code>if (gps(‘abc_myfile’)==‘myimage.gif’) {
header(‘Content-type: image/gif’);
echo base64_decode(‘iVBORw0KGgoAAAANSUhEUgAAADwAAAA1CAMAAAAqL….’);
exit(0);
}
</code>
To get the base64 of the image, you can either write a two liner that opens the file reads it and base64_encode()s it. Or you can use http://software.hixie.ch/utilities/cgi/data/data
Note that since each image-request will be a hit to the textpattern-frontpage including a db-connection, you do not want to this for very many images on one page.
Offline
Re: Standard location for plugin support files
Thank you Sencer. I’ll give this a try :)
Offline
#15 2005-11-11 09:07:30
- boblet
- Member
- Registered: 2005-08-08
- Posts: 53
Re: Standard location for plugin support files
Hi All,
I’m wondering how I can take some javascript embedded into a plugin and put it in a linked external file. It was initially called in the plugin like this:
<code>function jsPop() {
return <<<EOF
// some javascript inside <script> and HTML comment tags
EOF;
}</code>
I tried putting the javascript (excluding the script/comment tags) into an external file linked with <script src="/js/jsPop.js" type="text/javascript"></script>
, and deleting the function reference. I got Fatal error: Call to undefined function jsPop() in /textpattern/lib/txplib_misc.php(455) : eval()'d code on line 229
. It seems the plugin doesn’t know about the file, so I guess I have to add a reference to function jsPop(script location goes here?)
or something similar in the plugin. What should I add to the plugin so it knows where to look?
Thanks for any assistance!
peace – boblet
Last edited by boblet (2005-11-11 09:11:54)
Offline
Re: Standard location for plugin support files
Call your javascript using <script src="index.php?js=jspop" type="text/javascript"></script>
the parameter doesn’t have to be js that’s just what I use. Then in your plugin add something like.
<code>
if (gps(‘js’) == ‘jspop’) {
header(‘Content-type: application/x-javascript’);
//Do stuff
exit(0);
}
</code>
p. I would recommend adding your plugin author prefix (like hak_jspop) to the variable you are checking for just to prevent collision problems.
Shoving is the answer – pusher robot
Offline
Re: Standard location for plugin support files
Is there any way to use js, only on pages that include a call to a particular plugin that actually uses it? And how would that be accomplished in terms of code in the plugin?
Proud Canadian. Toronto Locksmith , Actualize Consulting
Offline