Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Including the Footer and Adding Additional Pages3:19 with Alena Holligan
In this video, we’ll add a third page to our site. We’ll use the technique we discussed last time to get the common menu and footer elements included in all three pages.
Update to html
index.php unordered list for our random items should have a class of "items".
Let's now create another include file to contain the shared code 0:00 from the bottom of the files. 0:03 We'll also create the catalog listing page and 0:05 include both the header and the footer into that. 0:07 >> I'm gonna go into index.php and then scroll to the bottom of the page. 0:10 The code from the closing content div with comment 0:14 through the end of the file will be the same on all our pages. 0:18 So let's put that in a separate include file. 0:22 Since this holds the footer of our site, I'm going to create a new file inside 0:25 the includes directory and name it footer.php. 0:29 Let's move the shared code from index.php to footer.php. 0:38 Now we add the PHP code to include the footer into index.php. 0:46 Include("inc/footer.php") and save the page. 0:53 We also need to update suggest.php to use this include file as well. 1:03 So let's copy the code and paste it into suggest.php. 1:07 Next, let's create a new file for the catalog landing page, catalog.php. 1:16 Again, we want to make sure that this file is in the root directory right next to 1:25 the other pages index and and suggest.php. 1:29 We want to include the header just like we've done in the other two pages. 1:34 Let's open our PHP tag, 1:38 include("inc/eader.php") and close our PHP tag. 1:40 Then we need the div for the page content as well as the title of the page. 1:49 H1 tag, Full Catalog. 1:59 Then we'll end this file by including the footer as well. 2:07 Open our PHP, include('inc/footer.php"). 2:10 Our books, movies, and music pages will all work essentially the same way. 2:20 They will display data about our items in our catalog. 2:24 We used include files for the header and footer to share code, but for 2:28 this file we're going to use the same page and 2:32 change the content slightly based on what page is be shown. 2:34 This is the same technique we'll be using to show an individual title for 2:38 each page even though our title tag is in a single header.php file. 2:43 We'll be adding the code for 2:49 differentiating these pages In another video. 2:50 But for now, let's update the menu so that books, movies and 2:53 music all link to our new catalog page. 2:57 As we do this, you'll be able to see how our technique of including files 3:00 already makes our code easier to maintain as our gallery grows. 3:05 We need to update the link, on three different webpages. 3:09 But since all three include the same header.php file, 3:12 we only have to make that change in one place. 3:16
You need to sign up for Treehouse in order to download course files.Sign up