Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Include and path to images

    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!

  • #2
    Regular Coder ahayzen's Avatar
    Join Date
    Jun 2009
    Posts
    110
    Thanks
    8
    Thanked 11 Times in 11 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The code in index.php is something like this:

    PHP Code:
    $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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •