Skip navigation
barts5
Currently Being Moderated

Is CSS what I need?

Dec 22, 2013 8:04 AM

Hello,

 

I have a pretty basic website that I have put together over the years - http://www.glennbartley.com/index.htm

 

The website is to showcase my photography. One goal I have is to create a custom header and footer that I can edit as needed and have this applied to the 1500-2000 individual pages (one for each species).

 

So for example:

 

I would like to have the header from this page: http://www.glennbartley.com/articles.htm

 

Applies to about 2000 pages that look like this: http://www.glennbartley.com/naturephotography/Ecuador/Birds/BOOTED%20R ACKETTAIL.html

 

Is there a relatively straightforward way to accomplish this task?

 

Thank you so much for any help you can offer.

 

Happy holidays!

 

Glenn

 
Replies 1 2 Previous Next
  • Currently Being Moderated
    Dec 22, 2013 9:59 AM   in reply to barts5

    You will love SSI (Server Side Includes) as an ideal solution.

    DW Templates not suited to a site this large.

     

    Here are some links:

     

    http://www.tizag.com/phpT/include.php

    http://www.smartwebby.com/web_site_design/server_side_includes.asp

    http://www.adobe.com/devnet/dreamweaver/articles/ssi-extension.html

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 22, 2013 12:07 PM   in reply to barts5

    You really should be using dynamic  technologies for a site this big.  Use  MySql databases for your content and PHP code to query the databases and pull content into a few pages. 

     

    As Ken said, you can put your site wide menus, headers and footers into includes, or if using CodeIgniter, create models and controllers to wrap pages around headers & footers.  Static HTML is really only good for small sites (20-30 pages).  Once you surpass that threshold, you need to think dynamically.

     

     

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 24, 2013 12:01 PM   in reply to barts5

    There's no way to automagically apply site wide includes into your current site.  That's something you do in the development phase.   I suspect you've put the cart way before the horse which is unfortunate because now you must go back and manually re-code your site with server-side include statements.   Or better still, put content into a database and re-build your site dynamically.

     

    PHP Solutions: Dynamic Web Design Made Easy

    http://foundationphp.com/phpsolutions/

     

     

    ❄  ☃  ❄

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 21, 2014 6:35 AM   in reply to barts5

    An include file is a fragment of code, not a complete HTML page. So, for example, you might have an include file that only contains this code:

     

    <p>Hello world</p>

     

    That's all that is in that file. I will name it 'foo.inc' (it can be named anything you want).

     

    Then you might also have a parent page that looks like this -

     

    <!doctype html>

    <html>

    <head>

    <title>A Parent Page</title>

    </head>

    <body>

    <?php include("foo.inc"); ?>

    </body>

    </html>

     

    I will name this file 'parent.php'.

     

    When you upload these two files and then browse to parent.php, you will see "Hello world" on the screen. If you look at the source for that file in your browser, you will see -

     

    <!doctype html>

    <html>

    <head>

    <title>A Parent Page</title>

    </head>

    <body>

    <p>Hello world</p>

    </body>

    </html>

     

    When your browser requests that page from the server, the server sees the include directive and executes it BEFORE uploading the page to your browser. In other words, the server includes the include file in your page.

     

    Now imagine that include file is mentioned in 100 pages. A change to that single include file will magically appear in those 100 pages. It's immensely convenient. To summarize, you would need to create the include file and save it. Then you would have to REPLACE the existing code on each page (the code that will be put into the include file) with the include directive, and upload both the include file and the modified parent pages.

     

    Now - you can do includes in HTML or PHP or ASP or .NET, or any of those server languages. The syntax and file naming restrictions are a bit different for each, but that's not a real challenge to overcome. What are you using as a filename extension for your files? Looks like it is "htm" or "html". Is that correct?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 21, 2014 9:16 AM   in reply to barts5

    That could work. Read the disclaimers on that linked article though and make sure you understand the downside of doing this. It's not a serious problem, though.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 21, 2014 10:55 AM   in reply to barts5

    You will definitely have to replace (in every page) the existing code for the element newly specified in the include file. You might be able to do that with a well-constructed find and replace.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 21, 2014 11:54 AM   in reply to barts5

    You can do a find and replace to each file in a selected folder, but there is no way to say just put this code on line 7.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 21, 2014 12:04 PM   in reply to barts5

    If "Line 6" is the same on all of the pages, you could do something like this with the Find & Replace tool...

     

    Find In: Entire Current Local Site

    Search: Source Code

    Find: the part of line 6 that is the same in each page

    Replace: the same part of line 6 as above followed by the include code

     

    Replace All

     

    (may want ot make a backup of your site before attempting this, mistakes can happen)

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 21, 2014 1:18 PM   in reply to barts5

    The downsides to doing it are these -

     

    1. If you do as the example shows (force every *.html page to be parsed by the server) then you will slow things down a bit since even HTML pages that contain NO PHP will be parsed

    2. You cannot have "<?" characters in your HTML (don't think this is so likely)

    3. 3 years from now when you come back to this site to do some maintenance, will you remember that *.html files can also legitimately contain PHP code?

     

    I think that's it.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 14, 2014 8:21 PM   in reply to barts5

    It's a mess. That page is not valid.... at all. It's got multiple opening body tags and no closing body or html tags.  Include files should be code snippets and not contain any html or body tags, which yours do. If you put those tags in your includes, and also have them in your main page, you'll end up with dupes.

     

    I also see this: <!-- prevent right-click -->

    Forget that. You can't protect your images on your web pages.

     

    http://www.glennbartley.com/naturephotography/birds/ACORN%20WOODPECKER .html

     

    >But when I load that page I do not see the header or footer.

     

    That's an html page, so it's not going to parse the php include code.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 15, 2014 9:40 AM   in reply to barts5

    You have placed your PHP calls for both include files outside the <body> section of your page.

     

    <head>

    <?php include("Header-Test.html"); ?>

     


    Move both to within the <body> section

     

    <body bgcolor="#000000" text="#CCCCCC" link="#CCCCCC" vlink="#CCCCCC" alink="#999999">

    <?php include("Header-Test.html"); ?>

     

    Same with the footer include (move it up just above the </body> tag).

     

    <?php include("Footer-Test.html"); ?>

    </body>

    </html>

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 15, 2014 9:52 AM   in reply to barts5

    >My understanding is that by modifying the htaccess file as I have done

    >I should be able to see the php code on my html page

     

    Ah sorry, I completely missed that part of the conversation. I'm not an expert in that particular subject so I'll defer to someone else.

     

    In the mean time, Ken is correct about proper placement of the includes, but you also still have problems with your included files. For example, this page:

     

    http://www.glennbartley.com/naturephotography/Footer-Test.html

     

    Has an opening body tag. Included files should not contain html, head or body tags. Theoretically, you could include an open tag in one SSI and closing tag in another, it's not recommended.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 16, 2014 3:04 PM   in reply to barts5

    >bregent - I dont know quite what you mean

    >about the html, head or body tags??

     

    Look at the source code in your header and footer files. You'll see they both contain a body tag. They both also contain the same javascript code which is redundant. Remove the body tag and either keep the javascipt in one file, or remove it completely and put in into the parent page.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 16, 2014 8:41 PM   in reply to barts5

    >OK so here is the code. I removed the body tag.

    >What else do I remove or change?

     

    OK, but the body tags are still in the files online. Did you upload them?

     

    >My understanding is that the script at the

    >top is to control the rollover images.

     

    Is it, but you only need the code once - you've got it in both files still

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 17, 2014 2:26 PM   in reply to barts5

    when I click on some pages / links in my site they download the file to my desktop instead of navigate to the page.

    You're using a local testing server on your computer, right?  PHP pages can't parse data without a server.

     

    Go to Edit > Preferences > Preview in Browser. 

    Under options:  turn off Preview with Temporary Files.

     

     

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 17, 2014 4:26 PM   in reply to barts5

    You realize some shared hosting plans won't allow you to use custom .htaccess files. 

    I know some folks here have told you could parse HTML documents if you create a custom .htaccess file but honestly your hosting provider is the only one who can determine that.

     

    When I need to use includes, I simply name my site pages with  .php or .shtml extensions and that takes care of that.

     

     

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 17, 2014 6:54 PM   in reply to Nancy O.

    Nancy's right. Have you checked with your host to see if they allow it? If they do, they should be able to provide you with the correct syntax for your .htaccess file. There are certainly other ones I've seen, for example:

     

    https://katz.co/use-htaccess-to-make-all-your-html-files-php/

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 17, 2014 9:51 PM   in reply to barts5

    Do ONE  test page saved as filename.php or filename.shtml and upload to your server.  If it works you know exactly what you need to do...

     

    Good luck,

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 18, 2014 11:17 AM   in reply to barts5

    <?php include("<?php echo $_SERVER['DOCUMENT_ROOT']; ?>Header-Test.html"); ?>

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 18, 2014 12:20 PM   in reply to barts5

    Sorry - my mistake. By the way, you should never use spaces or any punctuation other than period, dash or underscore in your filenames!

     

    <?php $filepath = $_SERVER['DOCUMENT_ROOT'] . 'Header-Test.html'; include($filepath); ?>

     

    Try that one.

     
    |
    Mark as:
1 2 Previous Next
Actions

More Like This

  • Retrieving data ...

Bookmarked By (1)

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