PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello PHP forum-
I have a weird problem that I have uncovered. It seems that my php include files render all my javascript references invalid. I am redesigning a site and this is seriously screwing things up for me.
On one of my test sites, I have been debugging all my XHTML/CSS stuff in one HTML so I wouldnt have to worry about parsing the page apart during the debugging phase. Now I have the skeleton of the page relatively bug free (I mean you can never account for IE completely), I want to apply my test site over to my template system in movable type. The way I have done this in the past is by using little php files for each part of my site (header, footer, etc) and then in the main page I just php include them all together. In my new design the structure is the same, but javascript is playing a much bigger role so this is a real problem now.
The links at the bottom of the header in all the following examples SHOULD produce a nifty little sliding javascript menu - which is how I know the code isnt working on the parsed version (tested on FF1.5, IE6 and Opera 9). I have done a number of checks and there is no real difference in the code, except the fact that Im doing a php include for the header in the last rendition.
Non-parsed purely HTML version outside of the MT system (the base code for the other pages - check the view source to see code)
http://www.humanproductivitylab.com/tes ... _test.html
The non-parsed version run through the MT engine (shows MT is NOT the problem, like I thought it might be):
http://www.humanproductivitylab.com/tes ... nscopy.php
The php parsed version run through the MT framework:
http://www.humanproductivitylab.com/test/
Here is the code of the parsed version because maybe Im just missing something real simple:
<?php
//included code for page header
include ('/home/hplmt/public_html/test/header.inc.php');
?>
<div id="container_content">
<div id="content_primary">
[content ommitted to save space]
</div>
<?php
//included code for rightnav column
include ('/home/hplmt/public_html/test/rightnav.inc.php');
?>
</div>
<?php
//included code for page footer
include ('/home/hplmt/public_html/test/footer.inc.php');
?>
I know the remote JS reference to the transmenu script in the header is correct because the remote stylesheet reference is working (and the transmenu script folder is on the same level as the template folder holding the CSS file) - so we can also rule that out. Is there a history of php includes breaking javascript that Im not aware of? If anybody can lend a hand, I would be most appreciative. I think our server is running PHP5 but Im not exactly sure which release.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
The difference you are pointing out pertains to when I was debugging to see if the problem was just in the path to the file. Turns out that file isnt even being referenced - its the 'transmenu_mod.js' file being referenced. Any other ideas?
If that is the case, why would the script work on 'whole' pages but break on PHP parsed pages? Why would breaking the page up change the functionality of the script?
I downloaded Firebug to try and see the error you are seeing - I am not seeing it. In my Firebug on FF 1.5.0.7 I see a green check in the the status bar, which I would take to mean there are no errors.
I dont know why this hasn't been said before (unless i missed it, or I'm wrong...), but php cant really "cause" any problems with javascript... as PHP is server side code and JS is client side... however, if your php created javascript is not outputting the correct code, then that could be the cause of the problem.
Take the full source code of the page that works...
Take the full source code (use the 'View Source' in your browser) of the php generated page
Compare them both... There will probably be a difference...
Well, after tons of debugging, it turns out that two of my javascrpts somehow disable each other. The ritecounter script bumps into the transmenu script...weird but true. Thanks for the help out there in forum land.
sujon wrote:I'll help u privately. If u feel interest then inform me.
sujon
1) He's resolved the issue; 2) Forums are here for everybody, if you give him a solution via PM and someone else comes across this same problem they will have to ask again because your solution wouldn't be public.