fazlionline Posted February 25, 2010 Report Share Posted February 25, 2010 I have created a menu in Adobe Fireworks CS3 Exported that, and copied all files to my main directory. I have linked the menu with <?php @include ('slidemenu03_sub.htm'); ?> It works fine in main page, see the link: http://fazlionline.com/v1/ Then I have created a folder named webdesign and copied index.php and past in webdesign folder, renamed it as web_design.php I changed the include code as: <?php @include ('../slidemenu03_sub.htm'); ?> I have just added ../ in there. Now when I brow http://fazlionline.com/v1/webdesign/web_design.php All images are missing and menu is not visible. Can anyone help me what is wrong Quote Link to comment Share on other sites More sharing options...
falkencreative Posted February 25, 2010 Report Share Posted February 25, 2010 If you check the source code, you'll notice that the include is working correctly. The issue, however, is that the links to the images are wrong. Here's a sample link: img3/home_f2.gif That will work fine on the home page, but it won't on the subpages (unless you make a copy of the "img3" folder and place it within the "v1" folder so the links work. A better option, however, would be to add an extra slash to the image links, like this: /img3/home_f2.gif That slash at the beginning tells the browser to go all the way back to your document root, and then to the img3 folder, and then finally to look for the image file. This way, the links to the images will be correct no matter whether the viewer is looking at the home page or a sub page. Quote Link to comment Share on other sites More sharing options...
Wickham Posted February 25, 2010 Report Share Posted February 25, 2010 A better option, however, would be to add an extra slash to the image links, like this: /img3/home_f2.gif That slash at the beginning tells the browser to go all the way back to your document root, and then to the img3 folder, and then finally to look for the image file. This way, the links to the images will be correct no matter whether the viewer is looking at the home page or a sub page. Remember that the root method won't work on your local computer which can be very inconvenient when testing your page. It only works from the hosting service server or from a server on your computer. Quote Link to comment Share on other sites More sharing options...
fazlionline Posted February 25, 2010 Author Report Share Posted February 25, 2010 Thanks both But adding slash with each image will WORK but what about links then. In home page my link was index.php and webdesign/web_design.php So what with links then When I am in ?v1/webdesign Folder, then index.php and webdesign/web_design.php Will also give error Is there any better solution Also for time being, I have just webdesign Folder, but later on, I want to add more folders like grapic_desing, domain_host, News, and more. So i have to make changes in each folder. In there any better solution Quote Link to comment Share on other sites More sharing options...
fazlionline Posted February 25, 2010 Author Report Share Posted February 25, 2010 A better option, however, would be to add an extra slash to the image links, like this: /img3/home_f2.gif But I have PHP Include function on each page which is calling menu. If I change it to /img3/home_f2.gif Then the main page will give error Quote Link to comment Share on other sites More sharing options...
falkencreative Posted February 25, 2010 Report Share Posted February 25, 2010 Then the main page will give error Test it. It won't give you an error. You can also do the same thing with links too, for example: /index.php and /webdesign/web_design.php The only limitation, as Wickham said, is that this only works when the site is uploaded to the server or viewed on a local server with something like MAMP or WAMP. Otherwise, either you'll need to use absolute links (http://www.yoursite.com/page.html) or figure out the correct relative link for the link/image. Quote Link to comment Share on other sites More sharing options...
fazlionline Posted February 25, 2010 Author Report Share Posted February 25, 2010 (edited) I have added slash to images, It is just replaced from: onmouseover="MM_swapImage('home','','img3/home_f2.gif',1);"> width="120" height="35" border="0" id="home" alt="" /> To: onmouseover="MM_swapImage('home','','img3/home_f2.gif',1);"> width="120" height="35" border="0" id="home" alt="" /> So the main change was just a slash before src="img3/home.gif" and a href="/index.php" now, please see the main page and sub page http://fazlionline.com/v1/index.php Two images are not working And even click on web design button is giving page error Edited February 25, 2010 by fazlionline Quote Link to comment Share on other sites More sharing options...
BeeDev Posted February 25, 2010 Report Share Posted February 25, 2010 (edited) have a small php file that has your URL stored in a string variable: <?php $base = 'http://fazlionline.com/v1'; ?> and include this php on top of all your main pages (not in include files), main pages = index.php, webdesign.php etc: <?php require_once('myUrlIncludeFile.php') ?> put this code inside the tag on the same main pages: Now even when your viewing the page http://fazlionline.com/v1/webdesign/web_design.php'>http://fazlionline.com/v1/webdesign/web_design.php all your links and images will be relative to http://fazlionline.com/v1/ (Only requirement is your images and links need to start with a forward slash as Ben mention above.) Now when you change your root folder from v1 to whatever folder just change $base and it will work properly. More info about the HTML tag: http://www.w3schools.com/TAGS/tag_base.asp Edited February 25, 2010 by BeeDev Quote Link to comment Share on other sites More sharing options...
fazlionline Posted February 27, 2010 Author Report Share Posted February 27, 2010 Hi BeeDev I was confused with some steps in your code 1- I have made a PHP file named "myUrlIncludeFile.php" And stored the following information there <?php $base = 'http://fazlionline.com/v1'; ?> 2 - Then I pasted the following code on very-top of each page <?php require_once('myUrlIncludeFile.php') ?> 3 - then past the following code in each page in tag But it didn?t work. Note: i didnt changes the slashes becaues when i do that, the image disapear form design wiev, (Like broken link) and when online, the LINK also shows INCORRECT/broken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.