Ok well I have a question. But I don't explain it really well since I am new to this. But I will try my best.
I have a menu list that I created.
<nav>
<ul class="sf-menu">
<li class="current"><a href="index.html">Home</a></li>
<li>
<a href="index-1.html">About Us</a>
<ul>
<li><a href="#">Providers</a></li>
</ul>
</li>
<li>
<a href="index-2.html">Services</a>
<ul>
<li><a href="#">Policies</a></li>
<li><a href="#">Forms</a></li>
<li><a href="#">Common Conditions Info</a></li>
</ul>
</li>
<li>
<a href="index-4.html">Contact Us</a>
<ul>
<li><a href="#">Directions</a></li>
<li><a href="#">Working Hours</a></li>
</ul>
</li>
<li><a href="index-3.html">Careers</a></li>
</ul>
</nav>
But there are 7 pages or so that use the same navigation.. And if I add more pages then they will use the same navigation.
Now here is the problem. If i add a new page then I have to go and update each of the 7+ pages individually.
Is there a way for me to create this menu 1 time and then change that and have it automatically change in the rest of the pages?
答案 0 :(得分:1)
You need to use a language like php or python to acheive this, this is why scripting languages like php were invented, when you need to add some dynamic behaviour to your website in your case you're trying to create a master page that controls all the links on your website http://hoolihan.net/blog-tim/2008/09/24/simple-masterpages-with-php/ here is a link to get you started
答案 1 :(得分:0)
You need to use a master page.
A Master Page is a page that contains markup and controls that should be shared across multiple pages in your site.
This then will allow you to only update the nav bar ONCE and it takes effect on every page. Google master pages and you will be able to set one up very easily; this will save you a bunch of time (especially when the website starts getting bigger and bigger).
check this link: http://code.google.com/p/jsp-decorator/
You can have a decorator - the master - for the pages that you want.
I use an xml to define which page has which decorator, something like:
<decorator name="name" page="decorator.jsp">
<pattern>/folderName/*</pattern>
<pattern>/folerName2/*</pattern>
</decorator>