Skip navigation
Currently Being Moderated

Server Side Includes

Jan 23, 2012 6:01 AM

I have set up a server side includes in my site, All the graphics work ok, but not the links to the other pages, it is not uploaded to the site yet so there is no point in go to the url, I have pasted the mark up below. can any one help please.

 

 

<div id="banner"><img src="images/banner968_238.jpg" width="968" height="238" alt="The Carpet and Flooring Consultant" />

  <div id="navigate"><ul id="MenuBar">

    <li> <a href="../index.html">Home</a></li>

    <li> <a href="../commercial-contract_carpet_and_flooring.html">Commercial</a> </li>

    <li> <a href="../residential-domestic_carpet_and_flooring.html">Residential</ a></li>

    <li><a href="../information.html">Information</a>

     <ul>

      <li><a href="../contact.html">Contact</a></li>

      <li><a href="../photo_slideshows/products.html">Product</a>     

       <ul>

        <li><a href="../photo_slideshows/picture_gallery_commercial.html">Commercial </a></li>

       <li><a href="../photo_slideshows/picture_gallery_residential.html">Residenti al</a></li>

       </ul>

    </li>

    <li><a href="../tips_and_tricks.html">Tips_and_Tricks</a></li>

    <li><a href="../newsletter.html">Newsletter</a></li>

   </ul>

  </li>

  <li><a href="../inspections.html">Inspections</a></li>

</ul>

    <p> </p>

    <script type="text/javascript">

// BeginOAWidget_Instance_2141544: #MenuBar

var MenuBar = new Spry.Widget.MenuBar2("#MenuBar", {

      widgetID: "MenuBar",

      widgetClass: "MenuBar  MenuBarRightShrink",

      insertMenuBarBreak: true,

      mainMenuShowDelay: 100,

      mainMenuHideDelay: 200,

      subMenuShowDelay: 200,

      subMenuHideDelay: 200

      });

// EndOAWidget_Instance_2141544

    </script>

  </div>

</div>

 
Replies
  • Currently Being Moderated
    Jan 23, 2012 6:07 AM   in reply to Jeffrey54 Lane

    Jeffrey54 Lane wrote:

     

    I have set up a server side includes in my site, All the graphics work ok, but not the links to the other pages, it is not uploaded to the site yet so there is no point in go to the url, I have pasted the mark up below. can any one help please.

     

     

    <div id="banner"><img src="images/banner968_238.jpg" width="968" height="238" alt="The Carpet and Flooring Consultant" />

      <div id="navigate"><ul id="MenuBar">

        <li> <a href="../index.html">Home</a></li>

        <li> <a href="../commercial-contract_carpet_and_flooring.html">Commercial</a> </li>

        <li> <a href="../residential-domestic_carpet_and_flooring.html">Residential</ a></li>

        <li><a href="../information.html">Information</a>

         <ul>

          <li><a href="../contact.html">Contact</a></li>

          <li><a href="../photo_slideshows/products.html">Product</a>     

           <ul>

            <li><a href="../photo_slideshows/picture_gallery_commercial.html">Commercial </a></li>

           <li><a href="../photo_slideshows/picture_gallery_residential.html">Residenti al</a></li>

           </ul>

        </li>

        <li><a href="../tips_and_tricks.html">Tips_and_Tricks</a></li>

        <li><a href="../newsletter.html">Newsletter</a></li>

       </ul>

      </li>

      <li><a href="../inspections.html">Inspections</a></li>

    </ul>

        <p> </p>

        <script type="text/javascript">

    // BeginOAWidget_Instance_2141544: #MenuBar

    var MenuBar = new Spry.Widget.MenuBar2("#MenuBar", {

          widgetID: "MenuBar",

          widgetClass: "MenuBar  MenuBarRightShrink",

          insertMenuBarBreak: true,

          mainMenuShowDelay: 100,

          mainMenuHideDelay: 200,

          subMenuShowDelay: 200,

          subMenuHideDelay: 200

          });

    // EndOAWidget_Instance_2141544

        </script>

      </div>

    </div>

     

    Probably because the include IS NOT in the same directory as the other pages???

     

    You have to remember that when you insert an include in a page which is outside the directory where the actual include is the links DO NOT change so the pages cannot be found.

     

    When working with includes I always use the full url in the include file to the pages and then at the point I'm ready to upload to the remote server I'll do a find and replace, changing the links to echo the remote full url.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 6:15 AM   in reply to osgood_

    When working with includes I always use the full url in the include file to the pages and then at the point I'm ready to upload to the remote server I'll do a find and replace, changing the links to echo the remote full url.

     

    That's alot of unnecessary work. Just use a root relative link. Include files should always use root relative links for best results (unless you feel like you want to use absolute links, but there is no functional advantage to doing so).

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 7:06 AM   in reply to MurraySummers

    Murray *ACP* wrote:

    That's alot of unnecessary work. Just use a root relative link. Include files should always use root relative links for best results (unless you feel like you want to use absolute links, but there is no functional advantage to doing so).

    Hummm Ive never been able to get root-relative includes to work for me that's why I always go the abosulte url link

     

    Ok I have this set up:

     

    index.php (in site root folder)

     

    about.php in PAGES folder

     

    INCLUDES folder in PAGES folder

     

    In INCLUDES folder menu.php:

    <a href="http://localhost/sitename/index.php">Home</a>

    <a href="http://localhost/sitename/pages/about.php">About</a>

     

    Root relative would be? /

     

    <a href="index.php">Home</a>

    <a href="about.php">About</a>

     
    |
    Mark as:
  • Jim Carpenter
    507 posts
    Apr 6, 2006
    Currently Being Moderated
    Jan 23, 2012 7:17 AM   in reply to osgood_

    When I set up SSI, I usually put them in their own directory. So my includes url would be: /includes/myinclude.inc.php

     

    That would point to an include called myinclude.inc.php that is in my includes folder. It works well using php and asp.... of course the asp include would have the asp extension

     

    Jim

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 7:52 AM   in reply to Jim Carpenter

    polar_bare wrote:

     

    When I set up SSI, I usually put them in their own directory. So my includes url would be: /includes/myinclude.inc.php

     

    That would point to an include called myinclude.inc.php that is in my includes folder. It works well using php and asp.... of course the asp include would have the asp extension

     

    Jim

     

     

    Yeah but if your pages were in a folder named 'monkey' the link would be ../includes/myinclude.inc.php? And your index.php is outside the 'monkey' folder - includes/myincludes.inc.php BUT what would the links look like in one of the include files because they surely would not be correctly linked to serve both the index.php and the pages in the 'monkey' folder?

     
    |
    Mark as:
  • Jim Carpenter
    507 posts
    Apr 6, 2006
    Currently Being Moderated
    Jan 23, 2012 7:56 AM   in reply to osgood_

    Sure they would.

     

    On any page the link would be the same, no matter where they were located and how deep in the directory structure. the / tell it to start at the root. So all of them would be the same.

     

    /(start at the root)/includes (the folder where the file resides)/myinclude.inc.php (the name of the file)

     

    It has always worked for me.

     

    Jim

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 8:03 AM   in reply to Jim Carpenter

    polar_bare wrote:

     

    Sure they would.

     

    On any page the link would be the same, no matter where they were located and how deep in the directory structure. the / tell it to start at the root. So all of them would be the same.

     

    /(start at the root)/includes (the folder where the file resides)/myinclude.inc.php (the name of the file)

     

    It has always worked for me.

     

    Jim

     

    Not talking about actually including the include file into a page, that's pretty simple. I'm trying to address the issue of the links inside the include files. If youre linking to pages in different directories I don't see how one include file can service all directories because the links in the include file don't change?? As I see it the only way is to use the absolute url for the links or keep the pages and the includes in the same directory.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 8:04 AM   in reply to Jim Carpenter

    When I set up SSI, I usually put them in their own directory. So my includes url would be: /includes/myinclude.inc.php

     

    You are misunderstanding the issue.

     

    It's the links CONTAINED in the include file that must be root relative, not necessarily the link TO the include file.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 8:06 AM   in reply to osgood_

    If the links are root relative they will work in any parent file in any folder of the site, since they always begin the path at the root of the site.

     
    |
    Mark as:
  • Jim Carpenter
    507 posts
    Apr 6, 2006
    Currently Being Moderated
    Jan 23, 2012 8:07 AM   in reply to osgood_

    The image links would be the same as the include, starting at the root.

     

      <a href="/PageDirectory/Page.php/">

      <img src="/images/timage.png" alt="myimage" width="140" height="111" border="0" />

      </a>

     

    The above is a prime example linking an image to a page in an include file

     

    Jim

     
    |
    Mark as:
  • Jim Carpenter
    507 posts
    Apr 6, 2006
    Currently Being Moderated
    Jan 23, 2012 8:08 AM   in reply to MurraySummers

    Yes Murray, you are correct. You taught this to me many years ago. Thanks.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 8:23 AM   in reply to Jim Carpenter

    <a href="/PageDirectory/Page.php/">

      <img src="/images/timage.png" alt="myimage" width="140" height="111" border="0" />

      </a>

     

     

    We'll its not happening for me.

     

    In the index.php page I have the following link but the link does not find the page_1.php

     

    <a href="/pages/page_1.php">

     

    only finds it if I drop the leading slash:

     

    <a href="pages/page_1.php">

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 8:58 AM   in reply to osgood_

    In the index.php page I have the following link but the link does not find the page_1.php

     

    <a href="/pages/page_1.php">

     

    only finds it if I drop the leading slash:

     

    <a href="pages/page_1.php">

     

    Are you talking about a local preview or a remote browse to this page?  If the former, it will only work if a) the index.php is in the root of the site, and b) if you have enabled temp files for preview.  If the latter, then there are other problems that we don't have enough information to solve.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 9:12 AM   in reply to MurraySummers

    Murray *ACP* wrote:

     

    In the index.php page I have the following link but the link does not find the page_1.php

     

    <a href="/pages/page_1.php">

     

    only finds it if I drop the leading slash:

     

    <a href="pages/page_1.php">

     

    have enabled temp files for preview.

     

    Well that could be it then....I've just done that. Will give it a test in a bit.

     

    Was beginning to think it could be something local that was not set up correctly and as its never worked locally I've never tried it on a remote, which was going to be my next step because I could NOT see how it was not working.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 9:15 AM   in reply to osgood_

    When you enable preview with temp files, and then preview a page, TWO things happen:

     

    1.  All root relative links are converted to document relative links, and

    2.  Certain related files linked in the page are actually embedded in the head (CSS and javascript externals)

     

    These two things are done in a temporary file which is what gets passed to the browser. 

     

    Just so you'll know....

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 9:20 AM   in reply to MurraySummers

    Humm well its getting closer.

     

    I still have the necessity to include the name of the site folder infront like:

     

    <a href="/siteFolderName/index.php">Home</a>

     

     

    So really that's not much better than the full url because I've still got to replace the site folder name when I upload to the remote server??

     
    |
    Mark as:
  • Jim Carpenter
    507 posts
    Apr 6, 2006
    Currently Being Moderated
    Jan 23, 2012 9:46 AM   in reply to osgood_

    If you don't want to have to replace it everywhere, if there are multiple instances, then you can use something like this to define the document root, if you are using php.

     

    <a href=($_SERVER['DOCUMENT_ROOT']."/index.php">Home </a>

     

    That would work anywhere you put it I think.. .right Murray?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 10:14 AM   in reply to osgood_

    That means that your site is not properly defined (DW is thinking that your local root folder is "siteFolderName".  Please check your definition for the site (also look on the Remote site definition, "Web URL" and see if that folder name is there too).

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 10:15 AM   in reply to Jim Carpenter

    It could.  Just depends on how the rest of things are set up.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 10:50 AM   in reply to Jeffrey54 Lane

    Jeffrey54 Lane wrote:

     

    Hi I am not sure where to start at the moment, here is my url:  http://www.thecarpetandflooringconsultant.co.uk My root file name is: consultant_cs5. How do I look on the Remote “web URL” to see if that name is there. Thanks Jeff

     

    Not sure what it is you are asking.......all your links appear to work?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 10:52 AM   in reply to osgood_

    My response (to which you appear to be directing your last post) was to osgood, not you. Sorry if you didn't catch that.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 10:59 AM   in reply to MurraySummers

    Murray *ACP* wrote:

     

    That means that your site is not properly defined (DW is thinking that your local root folder is "siteFolderName".  Please check your definition for the site (also look on the Remote site definition, "Web URL" and see if that folder name is there too).

     

    Sure its properly defined.  I have all my dynamic sites in library>webserver>documents. I set up a folder in the documents folder and define the site to point to that folder

     

    Testing server: /Library/WebServer/Documents/siteFolderName

     

    URL prefix: http://localhost/siteFoldername/

     

    Everything else works - it's always the way I've done it.

     

    Obviously / looks for something in 'localhost' but my site isnt in 'localhost' its in a 'folder' in 'localhost'

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 11:36 AM   in reply to osgood_

    Obviously / looks for something in 'localhost' but my site isnt in 'localhost' its in a 'folder' in 'localhost'

     

    Then that means your Remote site needs that folder explicitly mentioned in the Web URL.  Try it....

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 11:38 AM   in reply to MurraySummers

    Sorry - it's the TESTING server that needs it -

     

    for me, my local testing servers all have this in that field -

     

    http://192.168.1.82/foldername

     

    (but that is because my testing server is on another box - replace the IP with localhost if you are testing from your local workstation).

     
    |
    Mark as:
  • Jim Carpenter
    507 posts
    Apr 6, 2006
    Currently Being Moderated
    Jan 23, 2012 11:57 AM   in reply to Jeffrey54 Lane

    Jeffrey, are you using php, asp or shtml?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 12:38 PM   in reply to Jeffrey54 Lane

    Your parent pages (the ones that contain the include directives) must be named with a file extension that triggers a server parse.  This is usually "shtml", not "html".

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 24, 2012 1:06 AM   in reply to MurraySummers

    Murray *ACP* wrote:

     

    Sorry - it's the TESTING server that needs it -

     

    for me, my local testing servers all have this in that field -

     

    http://192.168.1.82/foldername

     

    (but that is because my testing server is on another box - replace the IP with localhost if you are testing from your local workstation).

     

    Nah still don't work.

     

    I can see it perhaps working if you have a virtual host set up as it cuts out the need for the browser to look in localhost>folder for the website. You sure that's not the set up youre working with, a virtual host?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 24, 2012 5:20 AM   in reply to osgood_

    I am working with a virtual host setup, but what I am telling you does not depend on that.  What do you have in the Server Folder, and the Web URL field of your Testing server definition?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 24, 2012 5:31 AM   in reply to MurraySummers

    Murray *ACP* wrote:

     

    I am working with a virtual host setup, but what I am telling you does not depend on that.  What do you have in the Server Folder, and the Web URL field of your Testing server definition

     

    I have this, as posted in one of my replies:

     

     

    Testing server: /Library/WebServer/Documents/siteFolderName

     

    URL prefix: http://localhost/siteFoldername/

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 24, 2012 5:41 AM   in reply to osgood_

    That will work with temp files enabled to PREVIEW a page containing root relative links.  You cannot click away from that page, however, because that will NOT work.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 24, 2012 5:49 AM   in reply to MurraySummers

    Murray *ACP* wrote:

     

    That will work with temp files enabled to PREVIEW a page containing root relative links.  You cannot click away from that page, however, because that will NOT work.

     

    Hummm.. well if I cannot click away from the page what's the point? How do I check the links are working? Might work ok on a remote set up which it should do but I'm guessing unless you have a virtual host set up which echoes the remote server behaviour it doesnt really work.

     

    I'll go back to the full url or may investigate a virtual host.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 24, 2012 5:51 AM   in reply to osgood_

    Clicking away from a page will not ever work unless you would have virtual hosts set up.  The preview will work (with or without virtual hosts) when you are using root relative links (like in your include files for images), but only if you have preview with temp files enabled.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 24, 2012 5:59 AM   in reply to MurraySummers

    Murray *ACP* wrote:

     

    Clicking away from a page will not ever work unless you would have virtual hosts set up.  The preview will work (with or without virtual hosts) when you are using root relative links (like in your include files for images), but only if you have preview with temp files enabled.

     

    All I wanted to do was check the include page links using / which I obviously cannot. But hey it was a wortwhile effort -  I now understand why they don't work, which really no one explains. Now I know and I know how to make it work if need be, set up a local virtual host. Not even Powers himself explains that well in his books about includes and their links although he has a whole bloody chapter on them to get the message across.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points