Page 1 of 1
adding javascripts same way as css ?
Posted: Tue Feb 20, 2007 8:31 pm
by rdg
is there, or there should be, a modul that u can ad a javascript the same way u can add css in the database and then to a page?
Re: adding javascripts same way as css ?
Posted: Wed Feb 21, 2007 12:49 am
by calguy1000
Use global content blocks.
that's what they're for. snippets of HTML code.
Re: adding javascripts same way as css ?
Posted: Sat Feb 24, 2007 3:33 am
by brady
I think this is a great idea,too. Global content blocks aren't quite what I want. Sure, you could use them to add some javascript, but when the javascript file is 15kb, that isn't a good option. So instead I have to upload them, find the correct address for them, and then add the script tag into the template. If javascript could be added just like the css is now, it would be amazing.
Re: adding javascripts same way as css ?
Posted: Sat Feb 24, 2007 6:51 am
by cyberman
Create a file with this inside
Code: Select all
<?php
function smarty_function_jinsert($params, &$smarty)
{
$files = explode(',', $params['files']);
foreach ($files as $file) echo '<__script__ type="text/javascript" src="uploads/js/'.$file.'"></__script>'."\n";
}
?>
save it as function.jinsert.php and upload it to /libs/smarty/plugins.
Now you can call many javascripts as you want with {jinsert files='script-1.js,script-2.js'}. Base path is uploads/js.