Home / The Lodge / The Big v10 Redesign Project / #021: Breaking Into Include-able Parts

#021: Breaking Into Include-able Parts

Now that we're running a custom local domain, we can use PHP. The "P" in MAMP is for "PHP" =). Using PHP means that we can use includes. For instance:

<?php include("header.php"); ?>

Our goal is to make a static "blog post" page to start messing around with. We could do that by duplicating our index.html page (now index.php), but we'd have lots of repeated code in that file if we did that. Remember, we're trying to stay as DRY (Don't Repeat Yourself) as possible.

We make a folder called "parts" in which to stick little reusable bits that are common to all pages. Like putting the DOCTYPE and head stuff into a part, the navigation, and the footer (for now just some closing tags) as well.

Now our index.php page and our blogpost.php both use several includes and only differ where it actually matters: the content.

We expand the possibilities of our grid a little bit by making a 2/3 1/3 setup, which we'll use more commonly on article-like pages.

We don't include the body tag, in case we need to change classes on it to use for styling page differently if it becomes useful to style based on a hierarchically high-up class.

We set up blogpost.php with real HTML from a real blog post. Because, as ever, it's better to design around real content than fake content. It's going to need a lot of work, but we have a great foundation to work from.