Question

I'm trying to put together a website that no-longer uses frames (my previously preferred method) but a singe page format.

One big problems I've found is that each page on the site will use the same menu. Now it occurs to me that if I amend the menu at a later date, then I'd have to change it on every page manually. This seems very time consuming and Inefficient.

Can anyone suggest ways I can alter the menu code once and have it on every page? I was thinking initially of embedding a javascript anchor to a js file on each page, then I would only have to change the js file. Are there better ways to do this?

The menu is a simple image and mix of text and anchor links.

I can program HTML/JS/CSS/C++ ... and willing to look at others if necessary to achieve my goals.

Thank you.

Was it helpful?

Solution

Make a separate partial view file containing your menu code and than include it on each page you need it to use the menu.

In PHP:

<?php require_once(__ROOT__.'/mainMenu.php'); ?>

In ASP something like:

<%@ Register src="~/mainMenu/mainMenu.ascx" tagname="MainMenu" tagprefix="uc" %>

<uc:MainMenu ID="MainMenu" runat="server />

Ideally you can expand this logic and create a master template page and than feed just the dynamic content in it - that keeps all your code on one place and makes changes very simple.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top