PHP include of menu not working

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
gjensen
Advanced
Advanced
Posts: 18
Joined: Fri Mar 04, 2005 2:38 pm

PHP include of menu not working

Post by gjensen »

What is the best way to seperate my js code from the rest of my code? I have tried to do a PHP include without success. Interestingly the code still shows up in the browser source, but not in the browser display.

If I embed the JS in the file all is fine.

Please advise.
George
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

I know the Milonic site is php, I don't know if they use includes, but I do know they rename the menu_data.js file to menu_data.php. I really don't know about php, so I'm not sure if that addresses your issue. Or if you are asking what the include code would be to include a js file?

Code: Select all

<?php include("js_file.inc"); ?>
Is one I saw on a search, but since I got that on a search I have no clue if it's even correct :?

Ruth
gjensen
Advanced
Advanced
Posts: 18
Joined: Fri Mar 04, 2005 2:38 pm

partly works

Post by gjensen »

I changed the name of the JS files to PHP and I can include those files.
but I still needed Milonic specific code down further in the content inorder to embed the menu at a certain location of the page layout. This is the code that shows up in the browser source, but will not work unless I put it statically into the file. Which would be tedious to maintain if i want to reuse that code in other files.
George
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

I think I didn't explain clearly. It's the menu_data file you name menu_data.php not the program files. They remain as .js files as far as I know. I've never seen anyone saying to convert the actual program files to php.

Ruth
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Ruth is correct. The menu code files must always remain as .js, but the _data file can be essentially anything - .js, .cfm, .php, etc. If you don't make the change your code in that file will never be parsed.
John
Post Reply