November 3, 200817 yr Hello! I try to write html-pages without resorting to softwares like dream weaver. As a newbie to the world of html/css, I have a following question and problem: As one CSS-file can determine the appeareance of web pages for some site, e.g. types of fonts, background, colors, etc., is it possible to make a file containing a section of html text such that can be imported automatically as a section of every web page of a site. For instance, a navigation menu is such a section of html text that every web page of some site contains. The reason for posting this question is that I try to avoid the tedious task of changing navigation menu in every page when adding new pages to the site. Must I manually write in every page the navigation menu, or is it possible to have one file that imports the navigation text to every page? Your response is very appreciated. Kind regards, Kalkas
November 3, 200817 yr I'm not entirely sure you are able to do this. In fact I'm pretty sure you will either need to use frames (bad idea), JavaScript or a server-side scripting language such as PHP or ASP.net.
November 3, 200817 yr Yes, I recommend using php includes for this. Your pages will need to be renamed with the .php extension, and of course you will need to make sure that php is installed on your server, but then you can just use the following to call in your nav or any other code: <?php include('path_to_file.php'); ?> easy If you want to see this in action on your computer before uploading to the net, you will need to install a local server. WAMP (windows) MAMP (mac) or XAMPP (linux). Good luck.
November 3, 200817 yr Author I'm not entirely sure you are able to do this. In fact I'm pretty sure you will either need to use frames (bad idea), JavaScript or a server-side scripting language such as PHP or ASP.net. Thanks for your reply. It is much appreciated! Best regards, Kalkas
November 3, 200817 yr Author Yes, I recommend using php includes for this.Your pages will need to be renamed with the .php extension, and of course you will need to make sure that php is installed on your server, but then you can just use the following to call in your nav or any other code: <?php include('path_to_file.php'); ?> easy If you want to see this in action on your computer before uploading to the net, you will need to install a local server. WAMP (windows) MAMP (mac) or XAMPP (linux). Good luck. Hello, Thanks for your reply! I see that I have to use php. I have never worked with php, but I am very familiar with html and css. Can you tell me more what kind of changes I have to make with my already existing html pages? My html pages are defined with the XHTML 1.0 Strict doctype. Every html page has a navigation menu, and I have about 30 pages. It is quite tedious to change this navigation menu when I want to add new links to new web pages; I use simple text editors as BBEdit with Mac, and Notepad with Windows. Is it just to change the extension of my web pages from html to php, and replace navigation menu with the php-code? The file containing the text of the navigation menu, should it be written as a html-page with the php-extension, containing <html> and <body> tags? Right now I am starting to learn about php scripting at www.w3schools.com http://www.w3schools.com/php/default.asp Kind regards, Kalkas
November 3, 200817 yr The include file doesn't have to be PHP, it can have any extension you like... <?php include('path_to_file.txt'); ?> <?php include('path_to_file.html'); ?> Unless you have any PHP code in the include, the include files can contain simple html, ie for your nav menu.
November 4, 200817 yr OK. Basically create your XHTML page for the navigation element only and call it something like 'navigation.php'. Then on each page you wish to include the navigation on (make sure the file extensions are set as .php) copy the following code to where you would like the navigation to be displayed. <?php include('navigation.php'); ?> Now you will have to do this for all of your current (30 or so) pages but once you have you will only ever have to change the 'navigation.php' file to edit the navigation site-wide.
November 5, 200817 yr Author Thanks for your reply. Your help is much appreciated. Kind regards, Kalkas
Create an account or sign in to comment