include problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chris

    include problem

    i have a page that INCLUDES another page but when the second page is
    included all the images are not showing.

    it is because the image url's are relative not absolute so the page is
    looking for the images relative to the main page location not the include
    page location - i dont want to have to change all the url's for the images -
    is there a way around this

    thanks in advance



  • Richard Grove

    #2
    Re: include problem

    "chris" <someone@here.c om> wrote in message
    news:3fe126c9$1 @funnel.arach.n et.au...[color=blue]
    > i have a page that INCLUDES another page but when the second page is
    > included all the images are not showing.
    >
    > it is because the image url's are relative not absolute so the page is
    > looking for the images relative to the main page location not the include
    > page location - i dont want to have to change all the url's for the[/color]
    images -[color=blue]
    > is there a way around this
    >
    > thanks in advance
    >[/color]


    You answered your own question.
    The image paths must be relative to the script that is trying to display
    them.

    and DONT cross post.

    Regards
    Richard Grove

    http://shopbuilder.org - ecommerce systems
    Become a Shop Builder re-seller:
    Affiliate marketing is a simple way to earn money online, using our affiliate platform. Join a global community of publishers and advertisers.

    Affiliate marketing is a simple way to earn money online, using our affiliate platform. Join a global community of publishers and advertisers.







    Comment

    • Shawn Wilson

      #3
      Re: include problem

      chris wrote:[color=blue]
      >
      > i have a page that INCLUDES another page but when the second page is
      > included all the images are not showing.
      >
      > it is because the image url's are relative not absolute so the page is
      > looking for the images relative to the main page location not the include
      > page location - i dont want to have to change all the url's for the images -
      > is there a way around this
      >
      > thanks in advance[/color]

      You may be able to use the <BASE HREF=""> html tag. But that would probably
      screw up the links and images on your first page.

      Or you may be able to use preg_replace to change the image SRC values. That may
      work well if you have consistent syntax in your html.

      Regards,
      Shawn
      --
      Shawn Wilson
      shawn@glassgian t.com

      Comment

      • Markus Ernst

        #4
        Re: include problem

        "chris" <someone@here.c om> schrieb im Newsbeitrag
        news:3fe126c9$1 @funnel.arach.n et.au...[color=blue]
        > i have a page that INCLUDES another page but when the second page is
        > included all the images are not showing.
        >
        > it is because the image url's are relative not absolute so the page is
        > looking for the images relative to the main page location not the include
        > page location - i dont want to have to change all the url's for the[/color]
        images -[color=blue]
        > is there a way around this
        >
        > thanks in advance
        >[/color]

        If the included page contains the whole HTML page as in:

        if(isset($_POST['something'])) {
        do something;
        include("otherp age.php");
        exit;
        }
        else {
        display page;
        }

        you could easily use

        header("Locatio n: otherpage.php") ;

        instead of the include command. Like that the url of the page you display
        corresponds to the actual place where the file is stored, so you don't have
        a relative path problem.

        HTH
        Markus


        Comment

        • chris

          #5
          Re: include problem


          "Shawn Wilson" <shawn@glassgia nt.com> wrote in message
          news:3FE1BC7A.1 AFA48F5@glassgi ant.com...[color=blue]
          > chris wrote:[color=green]
          > >
          > > i have a page that INCLUDES another page but when the second page is
          > > included all the images are not showing.
          > >
          > > it is because the image url's are relative not absolute so the page is
          > > looking for the images relative to the main page location not the[/color][/color]
          include[color=blue][color=green]
          > > page location - i dont want to have to change all the url's for the[/color][/color]
          images -[color=blue][color=green]
          > > is there a way around this
          > >
          > > thanks in advance[/color]
          >
          > You may be able to use the <BASE HREF=""> html tag. But that would[/color]
          probably[color=blue]
          > screw up the links and images on your first page.[/color]

          Thanks that worked i just did this and it worked great thanks

          <BASE HREF="relative link for the include file">
          <?php include("includ e file") ?>
          <BASE HREF="relative link for the main file">

          [color=blue]
          >
          > Or you may be able to use preg_replace to change the image SRC values.[/color]
          That may[color=blue]
          > work well if you have consistent syntax in your html.
          >
          > Regards,
          > Shawn
          > --
          > Shawn Wilson
          > shawn@glassgian t.com
          > http://www.glassgiant.com[/color]


          Comment

          Working...