Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS #include for loading page navigation no longer working

I've been using an #include to load my site navigation for the past several years. Now it no longer loads the navigation html. I have an #include for the top navigation and for the footer. The footer #include loads the footer on the home page, but on no other pages. The top nav #include was loading the navigation as of yesterday, but on no other pages. Now, today, it's not loading on the home page and no other pages. I've had another developer friend check it out and he is stumped as well. I've dumped browser and server caches, tried some different iterations of the #include statement. Nothing. No changes to that code or the code of the website have been made since before last March. Any suggestions? The site is blueplanetphoto.com Any help will be appreciated. Thanks!
 
What do you mean you are using an #include? AFAIK, there isn't a way to directly include an HTML file inside of another HTML file. Are you doing a PHP include? Seeing the code would be helpful.
 
This is what I've been using for years and it's worked just fine, until now:

HTML:
<body class="home page page-id-6 page-template-default _msp_version_2.14.2 sticky-header no-section-scroll smooth-scroll top-header all-ajax-content be-themes-layout-layout-box">
    <div id="main-wrapper">
        <div id="main" class="ajaxable layout-box">
            <!-- Header Nav start -->
            <header id="header">
                <!--#include file="topnav.html" -->
            </header>
            <!-- END HEADER -->
......

topnav.html is in the same directory as the pages loading the include.
The footer is the same, except for footer.html (which, as I posted, works on the home page but no other pages).

The topnav contains page links and dropdown menus.
footer contains, well, footer stuff.
 
Last edited by a moderator:
Ah, ok, looks like that syntax is ASP, so there's something dynamic that should be doing the include.

If it's always worked the same way and now it doesn't that suggests to me that something has changed. Do you manage this server, or do you have a webhost that does that for you? Maybe a config has changed that broke how pages are included or maybe an update did?

I'm not familiar with ASP at all, however shot in the dark here, what if instead of naming your page "index.html" you named it "index.asp". Does that fix the problem? I can see the include listed in your site's source code so I wonder if it's rendering as a straight HTML page instead of an ASP page.
 
I've also tried using php
PHP:
<?php include("phpincludes/topnav.html"); ?>
also
<?php $ipath = $_server["document_root"]. "/assets/php/"; include($ipath, "topnav.html"); ?>

No luck. I think there's been a change in the site code that I'm unaware of, that has disabled the <header> tag. That's where I'm at now.
 
What happens when you try the PHP? Does your server even support PHP? The original code you posted is Microsoft ASP code. I don't think it would be a typical setup for a server to support both ASP and PHP. Can you ask your hosts which languages your site supports? I'm guessing they changed something at some point which is why your site broke.
 
Nothing. Yes, my server does support php. The original code I posted is HTML, though it also works in ASP. I made changes consistent with php operations when I tested that option. The results were the same, no nav header.
 
When I have the site in Dreamweaver, it shows everything perfectly. Just as it always has been. It's when it's uploaded to the server that it gets wonky. That's why I'm looking at other aspects than the code, but don't understand why the nav header and footer (except for the home page) are the only elements being affected after having no issues and no code changes. Header and footer are also not showing on mobile.
 

New Threads

Buy us a coffee!

Back
Top Bottom