...

View Full Version : Include and path to images



weirdvision
06-23-2010, 11:48 AM
I'm trying to convert an old site that is currently using frames to PHP.

The directory structure is the following:

/articles
/articles/item1
/articles/item1.html
/articles.html
/index.php

In index.php I have the page item1.html included with 'include'. The page item1.html is displayed on the screen when included, but the images that should appear on it are not. The images associated to each itemX.html file are stored in an itemX subfolder of the articles folder. Is it possible to have images displayed without having to change the actual path in each html file? It's a pretty big site, over 400 pages, so I'm looking for minimum amount of changes needed. Thank you in advance!

ahayzen
06-23-2010, 12:03 PM
Would you be able to post the code for the pages you are using and the image paths?

It sounds like you need to look at the use of relative and absolute paths for the images.

Andy

weirdvision
06-23-2010, 12:57 PM
The code in index.php is something like this:


$id = $_GET["id"];
$cat = $_GET["cat"];

$path = '';

if ((!$id)||(!$cat)) {
$id = 'main';
$cat = 1;
}

switch ($cat) {
case 1: break;
case 2: $path = 'articles/';
break;
case 3: $path = 'interviews/';
break;
case 4: $path = 'photogallery/';
break;
case 5: $path = 'reports/';
break;
case 6: $path = 'archive/';
break;
}

include("left.html");

include($path.$id.'.html');


Let's say the requested page is 2010brian.html from the 'articles' folder. When displayed on the screen, the images show up as empty squares. The path seems to be 2010brian/image.jpg when in reality they are residing in articles/2010brian. I understand what is going on and why, I just need a way around it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum