Jump to content
Killersites Forums

Menu appears on home page but not in FOLDER pages


fazlionline
 Share

Recommended Posts

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:

 

 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

I have added slash to images,

It is just replaced from:

 

 

To:

 

 

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

 

 

Two images are not working

And even click on web design button is giving page error

Edited by fazlionline
Link to comment
Share on other sites

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 by BeeDev
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...