Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> RN v2.10.01 - All Issues
Author Message
southern
Client



Joined: Jan 29, 2004
Posts: 624

PostPosted: Mon Nov 26, 2007 3:04 pm Reply with quote

I have a javascript I want to use, it has a part that has to go in the head and another part that has to go just before the closing body tag at the end of the page. I can put the head part in javasc ript.php but where would the body part go? I'd like to make the two parts into separate .js files, I tried doing it with include(scripts/some.js) in header.php and some_foot.js in footer.php and it sort of worked except commented out text in the .js file showed lol so it's back to the drawing board... what about the custom header and footer folders in /includes? Thanks.

_________________
Computer Science is no more about computers than astronomy is about telescopes.
- E. W. Dijkstra 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Mon Nov 26, 2007 5:51 pm Reply with quote

Placing them in the custom folders will work.
 
View user's profile Send private message
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Mon Nov 26, 2007 6:37 pm Reply with quote

How is the Javascript getting called? I'm curious because I'm trying to understand why it would be important where it gets placed. In other words, if you put it in Javascript.php ... well the whole page gets laid down by the browser but the Javascript isn't executed until something in the page calls it. So why wouldn't it all work there?
 
View user's profile Send private message Visit poster's website
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Mon Nov 26, 2007 9:25 pm Reply with quote

GCalendar sprinkles Javascript all over the place in the body. This is because the code GCalendar generates is dependent in many cases on the content of the page and changes dynamically. So I could not put it in the header as I don't know what it will be until the modules is called, and by then it is too late for the header.

_________________
Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module 
View user's profile Send private message
Raven







PostPosted: Mon Nov 26, 2007 11:58 pm Reply with quote

Southern isn't saying that it can't be put elsewhere. He is just trying to follow the instructions he has been given. Good conventional web design calls for as much style and javascript to be placed in the <head></head> section as possible and then invoked through method calls as in onload(), onchange(), etc.

<head>
<script type="text/javascript" src="myscript.js"></script>
<link rel="stylesheet" type="text/css" href="main.css" />
</head>

Here's a pretty good write up http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
 
Gremmie







PostPosted: Tue Nov 27, 2007 6:39 pm Reply with quote

Sure, but script tags are allowed in the body. I was just trying to answer fkelly's query about why you would need them in the body.

If we had a different CMS where each module was queried for its javascript before generating the head section it could all be put in the header. But that isn't how PHP-Nuke is designed.
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Wed Nov 28, 2007 5:55 am Reply with quote

hhhmmmm.... sounds like another good enhancement idea, similar to the CSS one that was done for 2.20.00... Wink

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
fkelly







PostPosted: Wed Nov 28, 2007 8:58 am Reply with quote

With regard to your earlier answer Gremmie, and I'm not saying it is desirable, but could not all your Javascript be put into javascript.php that's loaded in header.php? Your Gcalendar code could still access it from there, no? I realize you might not know what code gets accessed until you get to a certain point in the Calendar but couldn't it be loaded anyway ahead of time?

For post 2.20 we really should look at putting common JS code such as email checks, zip code checks, phone number checks etc. into Javascript.php so that any module could call them.

And just as a general note, just this week I ran into a validation problem with a code modification I'm making in YA/admin/index.php. I created a ya_javascript.php file that is used in YA administration. I was including it at the top of the index.php -- not in the functions within that file. So it was getting stuck at the top of the generated web page, before the doctype that header.php puts out. So of course the page would not validate. The solution was to move it into the function after header.php was called but maybe over the long run we can look at re-sequencing things so that header.php is always called first. And I know it's a can of worms.
 
Gremmie







PostPosted: Wed Nov 28, 2007 9:48 am Reply with quote

For the GCalendar code I am thinking of in particular, I need to dynamically generate it based on _GET and _POST stuff. It's just easier to generate it with the rest of the module code while it is drawing the calendar, etc.

I'm sorry if we aren't answering Southern's original question or getting too far off topic here.
 
Display posts from previous:       
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> RN v2.10.01 - All Issues

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©