adding javascripts same way as css ?

Talk about new features for CMSMS and modules.
Post Reply
rdg

adding javascripts same way as css ?

Post 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?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: adding javascripts same way as css ?

Post by calguy1000 »

Use global content blocks.
that's what they're for.  snippets of HTML code.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
brady

Re: adding javascripts same way as css ?

Post 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.
Last edited by brady on Sat Feb 24, 2007 6:07 pm, edited 1 time in total.
cyberman

Re: adding javascripts same way as css ?

Post 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.
Last edited by cyberman on Mon Apr 23, 2007 4:47 am, edited 1 time in total.
Post Reply

Return to “Feature ideas”