You are here: Re: Making one HTML page from more than one file « HTML « IT news, forums, messages
Re: Making one HTML page from more than one file

Posted by J.O. Aho on 04/22/07 11:35

Manfred Preußig wrote:
> Adrienne Boswell schrieb:
>>> What I ment is you cant use the statment
>>>
>>> <?php
>>> include "filename.html";
>>> ?>
>>> on a file with an extension of .html it will not work the file has to
>>> be changed to .php.
>>> php is not used in PURE html
>> No, you can use anything in there, as long as the server can parse it.

It's generally bad to allow php parse extensions like .html, as they usually
wouldn't have any php code and to make a few files to work, it's better to
rename those and setup a server side redirection if you want old links still work.


> At the moment that's allready a question to me. I will ask the provider
> what I can do there.

They will tell you to rename yourfile.html to yourfile.php, it's bad to let
parse maybe thousand of html pages to make your handful pages to work, when
you can get things work with a simple rename.



>> However, I will say that one should not try to include an entire HTML
>> page within another, because one would get duplicate head elements.
> Of course. If I do it like this I will make it through a special page
> only for this. But even there it was the question if tags like <HTML>
> have to be in there too.

If you have a page like

--- example ---
<html>
<head><title>Title</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
</body>
<?php include 'navbar.php' ?>
Something
</body>
</html>
--- eof ---

Then you do not include any <html>-tag, nor head/body-tags, as the page will
look for the user like this:

--- example ---
<html>
<head><title>Title</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
</body>
<a href="index,php">Home</a><a href="www.example.net/page2.php">Another page</a>
Something
</body>
</html>
--- eof ---

If you add the <html>-tag, then you would get a none valid html code

--- example of bad code ---
<html>
<head><title>Title</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
</body>
<html><a href="index,php">Home</a><a href="www.example.net/page2.php">Another
page</a></html>
Something
</body>
</html>
--- eof ---

Some browsers may even not display this kind of broken page.


> The duplicate header I think I need at one
> point: To incorporate the CSS. Or is the setting in the including file
> valid for the included file too?

You don't need to include extra CSS for the included page, it will be using
the one you defined for the page, and I doubt you will be using different
CSS:es for each page, so you can have the part for the navbar in the main CSS.
In case you would have really special settings for each page, you break out
all that is common for each page, have it in once CSS that you include in each
page and then add just the CSS with page specific code in the header of each page.


>> As when replying to usenet posts, only include the relevant information.
> Sorry, I'm new user to usenet (in germany free servers for it are going
> less and web forums are going more) and in forums the handling is
> indifferent -some wants big quotes some not. Whatever you do -anybody
> put critics on it. So ... I know it for the future.

There is a long tradition on ng to just quote what you reply to, but of course
there are quite many microsoft influenced people who tend to include the whole
previous post (including footers that never should be quoted) and even top
post too.

--

//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация