Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10
  1. #1
    Junior Member
    Join Date
    Feb 2005
    Posts
    20
    Member #
    9129
    Ok, here's the deallio.

    I've got several domains, some of them reference the same files. For example's sake, we'll call the current directory I'm working in "current."

    The directory structure has all the domains on the same level, so I use for instance, the same footer file in each domain. Just say to keep things simple in this case that Util is a domain on the same level as all the others.

    So, I've just been referencing it with for instance

    Code:
    include "../../Util/public_html/footer.html";
    This works fine. However, I've run into an issue when I try to include a file that contains other files (in particular images) that it refers to.

    For instance I have a file called "navHeaders.html" that calls a few images inside of it. These images are in the same dir as navHeaders, the Util dir. So I have

    Code:
    include "../../Util/public_html/navHeaders.html";
    This calls the navHeaders file just fine, but all of the images are broken since it's looking for them in the dir I'm working in (current) even though the file that's calling them is in a different directory. navHeaders calls simply "image.jpg" Shouldn't it look for this in the directory navHeaders is in? Is there any way to get around this without having to upload all the images into my current working directory (since that defeates the purpose of all these different domains referrincing the same file anyway)?

    Thanks in advance.

  2.  

  3. #2
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    139 times
    Did you copy the same footer and whatnot into each domain, or are they all looking at the same file?

    Just change the call to image.jpg to ""../../Util/public_html/image.jpg" assuming Util can be accessed from multiple other domains.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  4. #3
    Junior Member
    Join Date
    Feb 2005
    Posts
    20
    Member #
    9129
    Quote Originally Posted by Wired
    Did you copy the same footer and whatnot into each domain, or are they all looking at the same file?
    I would like them to be able to all look at the same file, and not have to copy the footer and whatnot into each domain.

    Quote Originally Posted by Wired
    Just change the call to image.jpg to ""../../Util/public_html/image.jpg" assuming Util can be accessed from multiple other domains.
    I tried this, but for some reason I cannot get it working.

    Let's rework this to be more similar to what I'm actually doing.

    I have a main domain like www.sportsstuff.com

    Then I have many other domains like www.atlantasportsstuff.com, www.newyorksportsstuff.com, etc. They all have the same basic template, just that each of the team sites are of course more geared towards that team, but they all use the same footer, image row at the top, etc.

    So, in the sportstuff.com domain I have a footer.html, and imagerow.php. I don't want to have to copy those two files into every domain. sportstuff.com and all the team domains are on the same level.

    So, when in the index.php files for the team pages, I have

    Code:
    include "../../sportsstuff.com/public_html/imagerow.php";
    Now, that works fine, except that the images don't work. Within the imagerow.php file I have tried two things. The first is:

    Code:
    <img src="picture.jpg"
    This didn't work because it looked for it in my current working directory, like atlantasportsstuff.com, even though the file that was actually calling it is in the sportsstuff.com domain.

    The other thing I tried was:

    Code:
    <img src="../../sportsstuff/public_html/picture.jpg">
    This also did not work because it looked for the file in http://www.atlantasportsstuff.com/sp...ml/picture.jpg

    I tried adding another .. to the front of it and it still looked in the same place.

  5. #4
    Junior Member
    Join Date
    Feb 2005
    Posts
    20
    Member #
    9129
    Bumpity, anyone?

  6. #5
    Senior Member mossoi's Avatar
    Join Date
    Apr 2003
    Location
    Englandshire, United Kingdomsville y'all!
    Posts
    1,111
    Member #
    1206
    Liked
    1 times
    Have you tried using a base href in the head of each page? All links would then be referenced from that.

  7. #6
    Junior Member
    Join Date
    Feb 2005
    Posts
    20
    Member #
    9129
    Quote Originally Posted by mossoi
    Have you tried using a base href in the head of each page? All links would then be referenced from that.
    I'm not sure I'm following you here. I'll try googling this and post again.

  8. #7
    Senior Member mossoi's Avatar
    Join Date
    Apr 2003
    Location
    Englandshire, United Kingdomsville y'all!
    Posts
    1,111
    Member #
    1206
    Liked
    1 times
    If you're crossing domain why not just link to the full URL for the images?

    <img src="http://mydomain.com/images/image.jpg" />

    It's not elegant but it will get the job done.

    There is a PHP method to load the actual included file into the page that's calling it after it's parsed rather than including it before parsing.
    Code:
    <?php
          $fp = fopen("http://www.yourdomain.com/footer.php","r");
    	while(!feof($fp))
    	{
    	   $buffer = fgets($fp,"4096");
    	   echo $buffer;
    	}
    ?>

  9. #8
    Junior Member
    Join Date
    Feb 2005
    Posts
    20
    Member #
    9129
    I had thought about those two methods, but I was under the impression that it would slow down the loading of the page. Is that true?

  10. #9
    Junior Member
    Join Date
    Feb 2005
    Posts
    20
    Member #
    9129
    Ok now I can't get this working at all, even when it doesn't reference files in the same domain.

    Again, there are many domains. So the path to the main page is like /domains/sportsstuff/public_html/index.php

    sportsstuff is the main domain: like www.sportsstuff.com

    But then for say the atlantasportsstuff (www.atlantasportsstuff.com) it would be /domains/atlantasportsstuff/public_html/index.php

    So, I'm working in /domains/atlantasportsstuff/public_html/index.php

    and I have the following code:

    Code:
    include '../../sporsstuff.com/public_html/library.php';
    And I get the following error:
    Warning: main(../../sportsstuff/public_html/library.php): failed to open stream: No such file or directory in /home/admin/domains/atlantasportsstuff.com/public_html/index.php on line 2

    Warning: main(): Failed opening '../../sportsstuff.com/public_html/library.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/admin/domains/atlantasportsstuff.com/public_html/index.php on line 2

    Fatal error: Call to undefined function: title() in /home/admin/domains/atlantasportsstuff.com/public_html/index.php on line 6


    Even FURTHER, say that library.php referenced included other files of its own, it's ALSO looking for those files in the current dir rather than the dir that library.php is in.

    Although I guess I need to take it one step at a time and get the first part solved first...

  11. #10
    Member themayanlion's Avatar
    Join Date
    Mar 2005
    Posts
    40
    Member #
    9225
    i dont know if this helps, but when i first started using includes, i ran into this same problem.

    i'll try to answer as i understand your question (i do have the flu right now, so i may be a bit delirious, so i apologize if i'm repeating someone else's answer.)

    if this is the correct url for the page you are referencing

    Code:
    include '../../sporsstuff.com/public_html/library.php';
    then every image and similar element on that page has to have the same kind of url, since when you include the file, you are just making it a part of the file you are calling it from, so you have to reference all the images as if you were calling them from the page with the includes.

    for example, in a folder called library, you have library.php, and on that file you have an imamge in the same directory. image1.jpg. naturally, the source on library.php is just "image1.jpg".

    now let's say you have a mainpage.php file one level above the library.php. when you include the library.php onto the mainpage, you reference it like: include(library/library.php);

    mainpage.php treats it like it is an actual part of itself, so when the code is inserted, the src for the image is still just "image1.jpg". and of course, the image is actually one level beneath the mainpage.php file, so it doesn't show up.

    the solution is to go to your library.php page, and and change the src to act like it is calling it from the mainpage.php "library/image1.jpg". it will be broken on your library page, but when included into the mainpage, it will be fine.

    so basically, if your include above is correct
    Code:
    include {'../../sporsstuff.com/public_html/library.php');
    then any image on that page has to be given the same kind of src

    Code:
    include {'../../sporsstuff.com/public_html/image.jpg');
    it will be broken on the library page, but when included onto the page you are referencing it from, since it makes the library page a part of itself it will work.

    i hope that all made sense.
    i'm sure there is a better way to do it, but that's how i do it, since the sites i've used includes on aren't that complex. if you had lots of differnt files in differnt directories trying to call library.php, it probably wouldn't work.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:55 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com