Javascript Module

Talk about new features for CMSMS and modules.
Post Reply
180michael
Forum Members
Forum Members
Posts: 27
Joined: Fri Dec 26, 2008 9:29 pm

Javascript Module

Post by 180michael »

How about a simple module where you can write javascript files much like css and apply them to specific pages (or all) to be linked in the head section?
KO
Power Poster
Power Poster
Posts: 562
Joined: Mon Nov 06, 2006 7:55 pm

Re: Javascript Module

Post by KO »

Not bad idea. Or something similar to stylesheet module where you could include js to templates.
Zoorlat

Re: Javascript Module

Post by Zoorlat »

It already exists  ;)

Globel Content Blocks
are your friends, they are great for javascript.
KO
Power Poster
Power Poster
Posts: 562
Joined: Mon Nov 06, 2006 7:55 pm

Re: Javascript Module

Post by KO »

Global Content Block is great for online javascript which I never use. Same as with CSS styles which are files and not online styles. I link to JS files that could be stored in database. And that could be cached and not downloaded everytime with page.

Ofcourse you could use Global Content block to put the link to normal files stored in Server but you could do the same in templates. You don't need to use Global Content Block and do database query for that.
JeremyBASS

Re: Javascript Module

Post by JeremyBASS »

This is not a good idea, no offense but most people in here do not use js right and this could make it worse for others that don't know either...  shoving it all to the top, not minifying their scripts and the order of it all causing errors that just leads to "F" graded sites in ySlow.  If "they" can't get it right in the sites "they" build now how would a mod help ... the only way this would work is if there was a top and bottom out put, a pack or minify option, and if you could "move" the order of the scripts for each of top and bottom... there are more point to make it work as I'v thought alot on this... but over not a good idea unless those base points are covered...
My2Cents

jeremyBass
nhaack

Re: Javascript Module

Post by nhaack »

I usually insert static links to the JS files on the server in my templates. This reduces the DB queries to the required minimum and keeps the site fluid ;)

Alternatively, if I need dynamically generated JS files, I use a page based on an empty template and call this as my JS file (where I can mix smarty and JS to get what I need). Works very well for my cases. When the file is cached, it is not a big performance issue. The pages reside in a special folder I called "tools" that is not visible in navigation. As such, these "special pages" do not interfere with my regular content.

My 2 cents for the jar ;)

BEst
Nils
mtung
New Member
New Member
Posts: 4
Joined: Mon Jan 28, 2008 10:17 am

Re: Javascript Module

Post by mtung »

This thread seems somehow related to my current problem. I am trying to use external Javascript in CMSMS. However, when putting into my template


{literal}

{/literal}


it doesn't have any effect.---Could I also load Javascript code directly into an content page?

Many thanx, Mike
User avatar
duclet
Forum Members
Forum Members
Posts: 187
Joined: Fri Jun 23, 2006 12:55 pm

Re: Javascript Module

Post by duclet »

It looks like you are linking to a file absolutely from the root directory of your system rather than the root directory of your web site.
Zoorlat

Re: Javascript Module

Post by Zoorlat »

Duclet is right.
Also, for you don't need the {literal}-wrap.

Re. your second question. Yes you could also type the javascript directly into the content page, but then you will need to wrap that code inside {literal}-tags (otherwise smarty will try to execute all the {...} in your javascript).

Hope this helps!
Z
JeremyBASS

Re: Javascript Module

Post by JeremyBASS »

Yes you could also type the javascript directly into the content page
But you shouldn't unless you need a CMSMS var in it.. why?

http://developer.yahoo.com/performance/ ... l#external
http://developer.yahoo.com/performance/ ... #js_bottom
http://developer.yahoo.com/performance/ ... tml#minify

My2Cents


like duclet said as far as why your not finding the file... this may not be right...




I don't think you need this... /var/www/localhost/htdocs/ as if you type /var/www/localhost/htdocs/jsMath/easy/load.js in a broswer address bar you shouldn't find it...


try a relative path base on your web server root...
{literal}

{/literal}



but this is not related to this post here... ;D

cheers
jeremyBass
Last edited by JeremyBASS on Tue Jan 20, 2009 1:44 am, edited 1 time in total.
KO
Power Poster
Power Poster
Posts: 562
Joined: Mon Nov 06, 2006 7:55 pm

Re: Javascript Module

Post by KO »

Put {javascript} in your page template and then... oh sorry it was not invented yet;) Forget this.
try a relative path base on your web server root...
{literal}

{/literal}
I you put link in JS file in you page template (probably same in content) then you don't need {literal}. If you put actuall JS code then you do need tehm as JS has { and } which confuses SMARTY.
mtung
New Member
New Member
Posts: 4
Joined: Mon Jan 28, 2008 10:17 am

Re: Javascript Module

Post by mtung »

Many thanx for all the suggestions! As most of you indicated the problem was related to the path (however, there was no error message). Finally, the correct expression was


{literal}

{/literal}
...


I think it would be a good idea to have a module which allows to include external Javascript code.

Best, Mike
180michael
Forum Members
Forum Members
Posts: 27
Joined: Fri Dec 26, 2008 9:29 pm

Re: Javascript Module

Post by 180michael »

Being able to upload javascript inside CMSMS has its advantages. For one, it can be imported/exported just like templates and stylesheets. It really only makes sense to me to be able to enable some sort of feature for this so you don't have to ftp every time you need to edit a js file. In my case, we use a javascript framework often and need to add, subtract, or modify the code for changing elements on a page. It would also be helpful to be able to copy these files (like templates) and then edit the copy in minor details to then be included in specific cases.

As for questions about people messing things up with javascript, you should be able to set permissions just like with templates and stylesheets. Heck, with that logic any one could mess up there site by editing a template. With certain CMSMS powers come certain CMSMS responsibilities. If you can't stand the heat get out of the kitchen. For the rest of us who know this would speed things up, I think adding it would be taking a step in the right direction.
Post Reply

Return to “Feature ideas”