Hi all, I have a small website... I made it. www.RonenMymon.com It is simple and answers my needs for now... Here is my problem... I have the menu bar. and it is in EVERY page. Means, when I have something to change/add, I need to change/add in EVERY page... And I have a lot of pages.... Is there a better way (I'm sure there is) and simple to create one menu bar instance for all pages? (just to update once and all pages will take from same place). How do I do that?? And of course if you have any remarks or suggestions about my website.. I'll be happy to hear! Thanks!! Ronen
<?php include "includes/menu.php";?> This will call 1 menu to as many pages as you put the above code into. I use this for other things too like header/footer etc.
Hi! Thanks for your reply! What should be the index file type? shtml/html/htm? It doesn't seem to work for me....
I use this on my website, I have this: <?php include "menu.php";?> If you use like Scott said you have to upload the php file in the includes folder more tricky. Step one: Put above code where you want menu to appear (In Komposer Insert << Php). The page you put the code on can be .html or .htm (both are the same), I don't know if it works with .shtml You have to put the code on all webpages you want menu to appear but then just update the menu.php file to update them all. Step two: I use Komposer to create the website, just create your menu first in a new blank page, and then click Save As menu.php or whatever name you want. I have footer.php, leftmenu.php etc. Step three: Upload this menu.php file, as well as the html page/s with the php code in them to your website in the root folder (where index.html is). Optional step: I suggest before uploaded menu.php file to open the file using notepad and remove the stuff in <head> </head> just leave the contents in <body> </body> and remove html doctrine or whatever stuff above <head> is there. You do this to keep code clean and must be done each time you edit the php file. I personally took a course in html and css free online at: http://www.w3schools.com/html/default.asp This stuff sucks I know it's tricky. If you can't do this then hire a programmer for say $15 to set this up for you, guru.com (tell him also how he did it).
The index file needs to be PHP in order to recognize PHP code. head.php <html> <head> <title>My Title!</title> <!-- Stylesheet/meta tags etc --> </head> <body> HTML: menu.php <ul id="menu"> <li>Home</li><li>About Us</li><li>Contact</li> </ul> HTML: index.php <?php include "includes/head.php"; include "includes/menu.php"; ?> <h1>Welcome to my Homepage</h1> <p>Lipsom lorip blah blah</p> <?php include "includes/footer.php";?> PHP: aboutus.php <?php include "includes/head.php"; include "includes/menu.php"; ?> <h1>About Us</h1> <p>We are awesome!</p> <?php include "includes/footer.php";?> PHP: footer.php <!-- Footer code here --> </body> </html> HTML:
jacksarlo and scottlpool2003 Thanks a lot for your help! It works for a simple menu. just like in your example on top. Problems starting to accure when I'm trying my jQuery menu (taken from: http://apycom.com/). This is my menubar.php file: http://www.ronenmymon.com/MenuBar.php And this is my index.php: http://www.ronenmymon.com/index.php Getting some kind of 'no back link' error... do you know anything about it or should I address apycom.com ? Thanks again guys for your help !!
Not entirely sure what the problem is. Could be because its a free script that requires a backlink. I did notice you're including the JQuery codes twice though.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >>>>>>>>>> HERE <<<<<<<<<< <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Language" content="en-us" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Ronen Mymon :: Photographer</title> <style type="text/css"> .style9 { border-width: 0px; } .style11 { font-size: 8pt; text-align: right; font-size: 8pt; text-decoration: none; color: #000000; } </style> <link type="text/css" href="menu.css" rel="stylesheet" /> <!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script> --> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="menu.js"></script> <script src="Galleria/galleria-1.2.5.min.js"></script> >>>>>>>>>>>> HERE <<<<<<<<<<<<< <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-23422417-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <script> $(function(){ $('.fadein img:gt(0)').hide(); setInterval(function(){ $('.fadein :first-child').fadeOut() .next('img').fadeIn() .end().appendTo('.fadein');}, 3500); }); </script> <link type="text/css" href="menu.css" rel="stylesheet" /> <!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script> --> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="menu.js"></script> <script src="Galleria/galleria-1.2.5.min.js"></script> >>>>>>>>>> HERE <<<<<<<<<< </head> HTML: If you reply with the exact contents (including PHP), we'll be able to help further. I think you've added the code to both pages but its impossible for me to know without the contents of those pages.
I'd scrap that menu too its really annoying! Here's a similar one that works a little like the one you have. Demo: http://demos.myjqueryplugins.com/jmenu/ Instructions: http://www.myjqueryplugins.com/jquery-plugin/jmenu#field_implementation
I'll tell you what I do, which seems to me to be much easier than the other responses. My menu will always be a .swf file. And of course it's that same file on every page. So if I make a change to the menu or add something, I just upload the new menu and overwrite the .swf file with exact same name. Then all of the pages will automatically load the new file. This works as long as you don't change the actual size (dimensions) of the menu.
Great idea, give him Flash which effectively writes off the entire mobile/tablet traffic. There's nothing wrong with including files using PHP, and I actually think it is easier than using SWF, saves a lot of bandwidth, saves space...
Damn i forgot about mobile not supporting flash. Yeah I guess in that case it wouldn't be ideal. Your sarcasm makes you appear very bitter. I hope your ventures are doing well for you.
Flashtard BS for a menu should NEVER be done on a website, you basically throw accessibility in the trash and for what, a few goofy animated effects? The same can be said if you need that bloated idiotic crap known as jQuery to build a menu -- good scripting should ENHANCE functionality, not supplant it... and any goofy effects or advantages you get from the likes of jQuery on a menu is typically the type of crap that has no business on a website in the first place.
If you don't want to use PHP then prehaps and Iframe would be a better solution. Create all of your individual pages without any headers or footers and then create one page with the Iframe in it with a header and a footer. Give the Iframe a name and put each menu link's target as the name of the Iframe
Oh yes, iFrames -- the bleeding edge of 1997 sitebuilding methodologies that pisses all over accessibility -- SO worth suggesting.
Hi there! To address your question about creating a unified menu across all pages of your website, you can efficiently achieve this using server-side includes (SSI). This method allows you to maintain a single menu file that is included on every page, simplifying updates and ensuring consistency. ### Here’s a step-by-step guide: 1. **Create a Menu File:** - Start by creating a file (`menu.html` or `menu.php`) that contains your menu bar HTML code. For example: ```html <!-- menu.html --> <nav> <ul> <li><a href="index.html">Home</a></li> <li><a href="about.html">About</a></li> <li><a href="services.html">Services</a></li> <!-- Add more menu items as needed --> </ul> </nav> ``` 2. **Include the Menu File:** - Depending on your server setup, use one of the following methods: - **For HTML (using SSI):** ```html <!-- index.html --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Home</title> <!-- Other meta tags, stylesheets, etc. --> </head> <body> <!--#include virtual="menu.html" --> <!-- Your page content --> <h1>Welcome to My Website!</h1> <p>This is the homepage content.</p> </body> </html> ``` - **For PHP:** ```php <!-- index.php --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Home</title> <!-- Other meta tags, stylesheets, etc. --> </head> <body> <?php include 'menu.php'; ?> <!-- Your page content --> <h1>Welcome to My Website!</h1> <p>This is the homepage content.</p> </body> </html> ``` ### Benefits of using server-side includes: - **Efficient Updates:** You only need to update the menu in one file (`menu.html` or `menu.php`), and changes will automatically reflect across all pages. - **Consistency:** Ensures a uniform navigation experience for users across your entire website. For more details and examples on how to implement server-side includes, you can search for "server-side includes tutorial" or similar terms online. Hope this helps! Let me know if you have any further questions.