[pmwiki-users] php & javascript

Hans design at softflow.co.uk
Wed Nov 16 09:07:06 CST 2005

I like to incorporate a nice javascript into the skin template, which
will enable easy change of font sizes. To use pmwiki's capabilities for
internationalisations I would like to use some php(pmwiki) variables
inside the script. I know I could achieve this by using the
$HTMLHeaderFmt[] variable and load the script via this. But this will
bloat the html code for each page. My workaround at the moment is to
use $HTMLHeaderFmt[] and load the parts of the script with the
javascript variable definitions with pmwiki i18n, and load the
remaining script with   <script ... src=.....  ></script>.

This way I got less script code in the html source, but I wonder if
there is a good way to avoid it altogether.

To illustrate, here is the php code I use at the moment, with the
javascript snippet:

global $HTMLHeaderFmt;
$HTMLHeaderFmt[] = "
<script type='text/javascript' language='JavaScript1.2'>
    var bigger = new Array(11);
      bigger[0] = '<p>\$[Text Size]:<br/>';
      bigger[1] = ' \$[larger]  '; 
      bigger[2] = '\$[increase text size]';
      bigger[10] = ' | ';
    var reset = new Array(11);
      reset[0] = '';
      reset[1] = ' \$[default] ';
      reset[2] = '\$[reset text to default]';
      reset[10] = ' | ';
    var smaller = new Array(10);
      smaller[0] ='';
      smaller[1] = ' \$[smaller] ';
      smaller[2] =  '\$[decrease text size]';
      smaller[10] = '</p>';
<script type='text/javascript' language='JavaScript1.2' src='$SkinDirUrl/../fontsize.js'></script>

You can see the use of pmwiki i18n inside javascript variables.
But all this will show in the html page source.

Any ideas?

I know I could avoid javascript and have it all done with php, but for
this purpose javascript is so much faster, since it avoids page

Best regards,

More information about the pmwiki-users mailing list