I'm doing some testing with the php include so I can just have 1 menu and update in one location and for it to take effect over all pages.... my side_menu is located in the root directory and works fine with files within that root directory. ....BUT... When I add the side_menu to a file within a folder the images on my side menu do not show....yes I know the path has changed. But does this mean for each different path stage I need a new side_menu that will show the images with the correct path. eg. root: side_menu.html root/folder: side_menu1.html root/folder/sub_folder: side_menu2.html Or is they a better way around this...Or should I remove the images!! Ian
Hi Ian Don't give up on the menu, it's a great idea. Firstly... the images can be absolute paths so if I can see an image at http://mysite.com/images/menu/home.gif by calling it in my browser I can either use that in my menu or /images/menu/home.gif The benefit is the first / which tells the browser to go to the root of the domain and start looking from there - not from whereever it happens to be. Never, ever, user ../images/menu/home.gif - it's bad for the search engine bots and may end up with broken links. Now, I've been talking about images because you mentioned them, the same goes for pages: give them all their full links, then it doesn't matter where your menu is located, it will always work. good luck! Sarah
Thanks Sarah, It came to me about 2am this morning, about using the full path....Doh! But I wasn't going to get out of bed and try it. The none use of ../ and using / is a great tip, thanks. I use the full path for all pages - so guess I'm doing something right, one hell of a learning curve I'm on. Merry Crimbo & happy New Year. Ian P.S. Does this also mean the path for a CSS should be a full path at the moment I have ../../ when the file is in folders and sub folders.
I can agree with this. But ian_ok is asking about including a menu with php. As we all know PHP is a server side language. So before a bot views the page at the client side, it's already executed and html is written. So when you try to add a menu with PHP include, as soon as you can reach the menu it doesn't matter which way you use. IMHO, the easiest way is either put the menu file in the root folder and use /menu.inc or use the full path. If a site has several menus in several subfolders, it may get tricky, and you may want to use the full paths (urls). good luck
Hi Onestop We're in agreement actually, check the example - it's for a gif. I was trying to talk about how the reference to the menu items are written when they the items are in other folders. Believe it or not but there are sites out there that point to links and images - found this at random http://www.harrison.gen.nz/jc.king/index.html I just didn't want Ian to make the same mistake. Sarah
Wow Sarah once again you save the day I cant believe I didnt think of absolute URLs.. using sons of suckerfish css menu as an include and was stumped as to what to do as soon as I left the main folder.. all of a sudden my links to home page etc werent working! Sometimes its the easiest solution .. doh!! Now I can go have dinner amazing storm over auckland tonight huh!
Yeah - wild, wild night. My niece was flying to Wellington and was pretty freaked about what the landing would be like. Seems to have passed now though. Had the kids at swimming lessons in Mt Albert and the water was flooding INTO the pool complex, not out!
It will make it much easier for you with PHP includes to use BASEBATH variable. On any of your common pages, define a BASEBATH to be the basename for the website, then use that BASEBATH for the includes: define('BASEBATH', '/home/user/website/html'); So no matter where you are on the server, you can always do: BASEBATH . '/includes/menu.php' This will help you avoid problems when moving files around and it is the standard on most MVC application (including Zend, codeIgniter).