tags:

views:

46

answers:

2

I am developing a website that many pages share the same header/footer/sidebar/topbar.

Say I have three pages: one/index.php, second/index.php, third/index.php. They all share the same header/footer/sidebar.

The problem is where should I put the header/etc and its corresponding css file, since a piece of html code could not import css file.

What's a good way to modularize php/html page? Is there any good tutorial?

+2  A: 

Sounds like you may want a MVC framework and a template engine. Check out CodeIgniter, or TinyMVC with Smarty. Call external stylesheets with:

    <LINK href="special.css" rel="stylesheet" type="text/css">
Orbit
Thank for mentioning the framework. I have never thought and used framework before, it's maybe a right time to start learn.
Jichao
no problem, once you get the hang of it, you'll never go back
Orbit
The only problem now is the path of the css is relative to the require callee php file, but not the required html file.
Jichao
can just set to absolute with <LINK href="/path/to/special.css" rel="stylesheet" type="text/css">
Orbit
+1  A: 

You can use the PHP include statement to insert your header/footer/sidebar files where they need to be inserted in your other PHP pages.

Bill the Lizard