PDA

View Full Version : Call php or java?



waterdene
01-15-2008, 06:09 PM
1) Script Title: AnyLink Vertical Menu

2) Script URL (on DD): http://dynamicdrive.com/dynamicindex1/anylinkvertical.htm

3) Describe problem:
I have searched and found an assortment of posts that do not seem to be the answer to my problem. I want to have a "master template" of my menu that I can call to all pages on my site. It seems that I should create a php file and call this to each page, the problem is I cannot understand how to achieve this as there seems to be 3 parts involved.

The CSS style (No problem, I understand this)

The Javascript part (where do I save this to?)


<script type="text/javascript">

/***********************************************
* AnyLink Vertical Menu- Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="#">Quick Links<span style="position: relative; left: 74px"></span></a>'
menu1[1]='<a href="http://www.benal-life.com/XMLAttraction/arroyomap.htm">Benalmadena Maps</a>'
menu1[2]='<a href="http://www.benal-life.com/travel/travel.htm">Travel Shop</a>'
menu1[3]='<a href="http://www.benal-life.com/information/info.htm">Things Useful</a>'
menu1[4]='<a href="http://www.benal-life.com/travel/travel.htm">Local Travel Help</a>'
menu1[5]='<a href="http://www.benal-life.com/hotels.htm" class="navlist">Hotels and Hostels</a>'

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="http://www.benal-life.com/bars/bars.htm" title="Featured Bars in Benalmadena">Benalmadena Bars</a>'
menu2[1]='<a href="http://www.benal-life.com/restaurants/restaurants.htm" title="Featured Restaurants">Local Restaurants</a>'
menu2[2]='<a href="http://www.benal-life.com/businesses/business.htm" title="Featured Businesses">Local Business</a>'
menu2[4]='<a href="http://www.benal-life.com/weather_records/weather.htm" title="The Current and the forecast weather for Benalmadena">Weather Records</a>'
menu2[3]='<a href="http://www.benal-life.com/latest_updates.htm" title="The most recent of our pages to have major updates">Latest Updates</a>'
menu2[4]='<a href="http://www.benal-life.com/daysout/daysout.htm" title="Recommended days out with routes, pictures & maps">DIY Excursions</a>'
menu2[5]='<a href="http://www.benal-life.com/golf.htm" title="Golf and the golf courses of the Costa del Sol">Golf</a>'
menu2[6]='<a href="http://www.benal-life.com/fiestas/fiestas.htm" title="Things you might like to know about the many public holidays in spain">Parades & Fiestas</a>'
menu2[7]='<a href="http://www.benal-life.com/artistes/artistes.htm" title="A Free to join directory of Artistes and Entertainers on the Costa del Sol">Performers Directory</a>'
menu2[8]='<a href="http://www.benal-life.com/dementia/opener.htm" title="Do you think that you are safe from dementia?">An amusing test</a>'


//Contents for menu 3, and so on



and finally the navlist script which I presume is the part that I create the php file from



<ul class="navlist">

<li><a href="http://www.benal-life.com">Home Page</a></li>
<li onMouseover="dropdownmenu(this, event, menu2, '150px')" onMouseout="delayhidemenu()"><a href="#">Quick Links<span style="position: relative; left: 70px">&raquo;&raquo;</span></a></li>
<li><a href="http://www.benal-life.com/XMLAttraction/arroyomap.htm">Benalmadena Maps</a></li>
<li onMouseover="dropdownmenu(this, event, menu3, '150px')" onMouseout="delayhidemenu()"><a href="http://www.benal-life.com/travel/travel.htm" title="Travel deals from some of the best high street names">Travel Shop<span style="position: relative; left: 68px">&raquo;&raquo;</span></a></li>
<li onMouseover="dropdownmenu(this, event, menu4, '150px')" onMouseout="delayhidemenu()"><a href="http://www.benal-life.com/information/info.htm" title="A selection of informative things you need to know about Spain and the Costa">The Useful Index<span style="position: relative; left: 42px">&raquo;&raquo;</span></a></li>
<li onMouseover="dropdownmenu(this, event, menu5, '150px')" onMouseout="delayhidemenu()"><a href="http://www.benal-life.com/hotels.htm" title="Book your Hotel at the cheapest price available">Hotels & Hostels <span style="position: relative; left: 41px">&raquo;&raquo;</span></a></li>
<li><a href="http://www.benal-life.com/cpg1413/index.php" title="Members gallery where you show the world your photographs of Benalmadena">Picture Gallery</a></li>
<li><a href="http://www.benal-life.com/chat/" title="THE BEST place to chat about Benalmadena and Arroyo de la Miel">Benalmadena Forum</a></li>
<li><a href="http://www.benal-life.com/theme.htm" title="The sun has got his hat on and he's coming out to play">Cheer up with our song</a></li>
<li onMouseover="dropdownmenu(this, event, menu6, '150px')" onMouseout="delayhidemenu()"><a href=""#"" title="If you are travelling you might like to check out these sites">Travel Essentials<span style="position: relative; left: 40px">&raquo;&raquo;</span></a></li>
<li onMouseover="dropdownmenu(this, event, menu7, '150px')" onMouseout="delayhidemenu()"><a href="http://www.benal-life.com/shopping/travel/linktravelpackages.htm" title="The BEST of the package holiday companies operating in the UK">Package Holidays <span style="position: relative; left: 31px">&raquo;&raquo;</span></a></li>

</ul>


Even if my presumptions are correct I am still unsure of what to do with the javascript part of the code - help please

ddadmin
01-16-2008, 03:33 AM
Well, for the JavaScript portion, you can just save the entire contents (minus the surrounding <script> tags) into an external .js file, then reference that file on your page:


<script src="displaydate.js" type="text/javascript">
</script>

Here's a more detailed tutorial (http://www.javascriptkit.com/javatutors/external.shtml) on the process.

Regarding the HTML, it really depends on the type of your pages. For example, if they're .html (SSI), you'd use the includes ability (http://www.javascriptkit.com/howto/ssi2.shtml) of SSI to do your work.

waterdene
01-16-2008, 09:42 AM
Thank you very much that is just what I needed

waterdene
01-16-2008, 01:53 PM
All seemed well until I uploaded the page and scripts, although everything is fine when run locally the page is appearing blank when run from my server.

here is the code and url for the page
http://www.benal-life.com/java_nav/java_nav_good.htm



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>

<link href="/java_nav/vertical.css" rel="stylesheet" type="text/css">

<script src="/java_nav/vertical.js" type="text/javascript"></script>


<script type="text/javascript">
/***********************************************
* AnyLink Vertical Menu- Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
</head>
<body>
<!--#include virtual="/java_nav/menu.htm"-->
</body>
</html>


The menu (menu.htm)


<ul class="navlist">
<li><a href="http://www.benal-life.com">Home Page</a></li>
<li onMouseover="dropdownmenu(this, event, menu2, '150px')" onMouseout="delayhidemenu()"><a href="#">Quick Links<span style="position: relative; left: 68px">&raquo;&raquo;</span></a></li>
<li><a href="http://www.benal-life.com/XMLAttraction/arroyomap.htm">Benalmadena Maps</a></li>
<li onMouseover="dropdownmenu(this, event, menu3, '150px')" onMouseout="delayhidemenu()"><a href="http://www.benal-life.com/travel/travel.htm" title="Travel deals from some of the best high street names">Travel Shop<span style="position: relative; left: 68px">&raquo;&raquo;</span></a></li>
<li onMouseover="dropdownmenu(this, event, menu4, '150px')" onMouseout="delayhidemenu()"><a href="http://www.benal-life.com/information/info.htm" title="A selection of informative things you need to know about Spain and the Costa">The Useful Index<span style="position: relative; left: 40px">&raquo;&raquo;</span></a></li>
<li onMouseover="dropdownmenu(this, event, menu5, '150px')" onMouseout="delayhidemenu()"><a href="http://www.benal-life.com/hotels.htm" title="Book your Hotel at the cheapest price available">Hotels & Hostels <span style="position: relative; left: 36px">&raquo;&raquo;</span></a></li>
<li><a href="http://www.benal-life.com/cpg1413/index.php" title="Members gallery where you show the world your photographs of Benalmadena">Picture Gallery</a></li>
<li><a href="http://www.benal-life.com/chat/" title="THE BEST place to chat about Benalmadena and Arroyo de la Miel">Benalmadena Forum</a></li>
<li><a href="http://www.benal-life.com/theme.htm" title="The sun has got his hat on and he's coming out to play">Cheer up with our song</a></li>
<li onMouseover="dropdownmenu(this, event, menu6, '150px')" onMouseout="delayhidemenu()"><a href=""#"" title="If you are travelling you might like to check out these sites">Travel Essentials<span style="position: relative; left: 35px">&raquo;&raquo;</span></a></li>
<li onMouseover="dropdownmenu(this, event, menu7, '150px')" onMouseout="delayhidemenu()"><a href="http://www.benal-life.com/shopping/travel/linktravelpackages.htm" title="The BEST of the package holiday companies operating in the UK">Package Holidays <span style="position: relative; left: 28px">&raquo;&raquo;</span></a></li>
</ul>

The Javascript code (vertical.js)


//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="#">Quick Links<span style="position: relative; left: 74px"></span></a>'
menu1[1]='<a href="http://www.benal-life.com/XMLAttraction/arroyomap.htm">Benalmadena Maps</a>'
menu1[2]='<a href="http://www.benal-life.com/travel/travel.htm">Travel Shop</a>'
menu1[3]='<a href="http://www.benal-life.com/information/info.htm">Things Useful</a>'
menu1[4]='<a href="http://www.benal-life.com/travel/travel.htm">Local Travel Help</a>'
menu1[5]='<a href="http://www.benal-life.com/hotels.htm" class="navlist">Hotels and Hostels</a>'

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="http://www.benal-life.com/bars/bars.htm" title="Featured Bars in Benalmadena">Benalmadena Bars</a>'
menu2[1]='<a href="http://www.benal-life.com/restaurants/restaurants.htm" title="Featured Restaurants">Local Restaurants</a>'
menu2[2]='<a href="http://www.benal-life.com/businesses/business.htm" title="Featured Businesses">Local Business</a>'
menu2[4]='<a href="http://www.benal-life.com/weather_records/weather.htm" title="The Current and the forecast weather for Benalmadena">Weather Records</a>'
menu2[3]='<a href="http://www.benal-life.com/latest_updates.htm" title="The most recent of our pages to have major updates">Latest Updates</a>'
menu2[4]='<a href="http://www.benal-life.com/daysout/daysout.htm" title="Recommended days out with routes, pictures & maps">DIY Excursions</a>'
menu2[5]='<a href="http://www.benal-life.com/golf.htm" title="Golf and the golf courses of the Costa del Sol">Golf</a>'
menu2[6]='<a href="http://www.benal-life.com/fiestas/fiestas.htm" title="Things you might like to know about the many public holidays in spain">Parades & Fiestas</a>'
menu2[7]='<a href="http://www.benal-life.com/artistes/artistes.htm" title="A Free to join directory of Artistes and Entertainers on the Costa del Sol">Performers Directory</a>'
menu2[8]='<a href="http://www.benal-life.com/dementia/opener.htm" title="Do you think that you are safe from dementia?">An amusing test</a>'


//Contents for menu 3, and so on
var menu3=new Array()
menu3[0]='<a href="http://www.benal-


I have tried viewing on Firefox and IE6 - what am I doing wrong please??

ddadmin
01-17-2008, 09:17 AM
The file extension for your page online (.htm) is most likely static, and hence the include() statement isn't being interpreted. It should be something like .shtml assuming your server is set to recognize that as SSI enabled pages.

waterdene
01-17-2008, 10:29 AM
Thanks, I am sorry I should have read the link you pointed me at earlier in this post