02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

158<br />

CHAPTER 4 ■ BUILD AN EVENTS CALENDAR<br />

Creating the Common Files—Header <strong>and</strong> Footer<br />

There are going to be multiple pages viewed <strong>by</strong> your users in this application, <strong>and</strong> they all need a<br />

common set of HTML elements, style sheets, <strong>and</strong> more. To simplify maintenance as much as possible,<br />

you’ll be using two files—header.inc.php <strong>and</strong> footer.inc.php—to contain those common elements.<br />

First, create a file called header.inc.php in the common folder<br />

(/public/assets/common/header.inc.php). This file will hold the DOCTYPE declaration for the HTML <strong>and</strong><br />

create a head section that contains a Content-Type meta tag, the document title, <strong>and</strong> links to any CSS files<br />

required for the document.<br />

Because the document title will vary from page to page, you’ll be setting a variable—$page_title—<br />

to store each page’s title.<br />

Also, because more than one CSS file may be needed for a page, an array of CSS file names will be<br />

passed in a variable called $css_files <strong>and</strong> looped through to generate the proper markup.<br />

Inside this file, place the following code:<br />

<br />

<br />

<br />

<br />

<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!