Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2005-10-10 22:32:20

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

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

#14 2005-10-11 08:01:06

Skubidu
Archived Plugin Author
Registered: 2004-10-23
Posts: 611
Website

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

#16 2005-11-11 13:45:36

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

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

#17 2005-11-13 20:21:40

1beb
Plugin Author
From: Canada, Ontario, Toronto
Registered: 2004-11-22
Posts: 169
Website

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?

Offline

Board footer

Powered by FluxBB