Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML Reusable HTML

jgnordby

New Coder
This is my first post here, so please bear with me a little bit. A little background would seem appropriate, and I will move it to my profile when I can get a chance.



I have been working with computers, mostly on the software side since 1976. Yes, I did use the boxes and boxes of FORTRAN cards. Over the years since then I have been involved in a lot of projects, some small, and some VERY large. I have built small reporting systems before the internet when we (I was Air Force) used the ARPANET. I have also worked on missile defense systems, missile guidance systems, and many others.

The last project I worked on was to build Avionics system for NASA On the International Space Station (this was when the contract first started) and in the late 90’s I worked on a project to upgrade the Space Shuttle avionics systems too, hold on to your hat, an 80286 processor from an 8088.

I have a Masters Degree in Software Engineering; an MBA and I was one of the first people in the country to get a pure Professional Engineering (P.E.) license in Software Engineering. Before I retired, I did complete one web site for the U.S. State Department (internal use only).

I retired in 2001 and have not done a lot of development since, but I did still keep up with the industry and worked on Standards and Practices for Software Engineering.

Now, onto more recent things. I am building a new web site for a training business I want to start, on the side. I would say I am a low intermediate in HTML and CSS. However, my scripting skills are pretty much nil, with just a little bit of exposure to JavaScript.


My Issue/Question;

My site has a menu bar across the top (these items are the different training areas I teach):

Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7 Item 8 Item 9

When you hover over one item a pop-down list (the classes I teach in that area) will appear and you can select one from the list. Once a class is selected it will take you to that page (there are currently 40 pages). I repeat this menu at the top of every page. This way the user can jump around the site selecting any class in any area they want.

The bloc of code that builds the menu is about 200 lines of HTML & CSS. Once created, then and only then, can I get about the business of what I want done on the page. The menu code does make heavy use of CSS and I am using the Grid Layout System.

My question is about this menu and its selections. I have it all laid out in HTML & CSS, but I have to repeat the code on every page. Is it possible to create the menu once and then call it from each page? Thus, for any page it would be a one-line call to create the whole menu. The call could be to another HTML file or maybe a scripting file? I just do not want to copy and paste the menu code on 40 pages and when I make a change, I have to change it in all 40 files

I know how to do this in languages like Ada and C, C++, but not here. Is there a way to do this? Is there a thread already on here that discusses this?

Thanks in advance,

JGN
 
I have always used PHP to do this. It can be done with one of four commands:
include() and include_once()
require() and require_once()
I normally use include();
You save the HTML code under a name. "menu" would be good. and call it with:
Code:
<?php
include('menu');
?>

The menu code does not have anything but the code you wish to insert so no header, etc..
 
let me get this correct
The php file would be something like menu.php. It would only contain the html code I want to be called
The html file would have;
<?php
include('menu');
?>

did I get this right. I have 0 experience with php
 

New Threads

Buy us a coffee!

Back
Top Bottom