1 00:00:00,320 --> 00:00:03,760 Let's now create another include file to contain the shared code 2 00:00:03,760 --> 00:00:05,530 from the bottom of the files. 3 00:00:05,530 --> 00:00:07,800 We'll also create the catalog listing page and 4 00:00:07,800 --> 00:00:10,390 include both the header and the footer into that. 5 00:00:10,390 --> 00:00:14,830 >> I'm gonna go into index.php and then scroll to the bottom of the page. 6 00:00:14,830 --> 00:00:18,750 The code from the closing content div with comment 7 00:00:18,750 --> 00:00:21,049 through the end of the file will be the same on all our pages. 8 00:00:22,190 --> 00:00:24,200 So let's put that in a separate include file. 9 00:00:25,350 --> 00:00:29,140 Since this holds the footer of our site, I'm going to create a new file inside 10 00:00:29,140 --> 00:00:34,129 the includes directory and name it footer.php. 11 00:00:38,000 --> 00:00:42,450 Let's move the shared code from index.php to footer.php. 12 00:00:46,142 --> 00:00:50,843 Now we add the PHP code to include the footer into index.php. 13 00:00:53,777 --> 00:01:03,190 Include("inc/footer.php") and save the page. 14 00:01:03,190 --> 00:01:07,380 We also need to update suggest.php to use this include file as well. 15 00:01:07,380 --> 00:01:12,220 So let's copy the code and paste it into suggest.php. 16 00:01:16,394 --> 00:01:21,623 Next, let's create a new file for the catalog landing page, catalog.php. 17 00:01:25,510 --> 00:01:29,999 Again, we want to make sure that this file is in the root directory right next to 18 00:01:29,999 --> 00:01:32,737 the other pages index and and suggest.php. 19 00:01:34,200 --> 00:01:37,170 We want to include the header just like we've done in the other two pages. 20 00:01:38,860 --> 00:01:40,162 Let's open our PHP tag, 21 00:01:40,162 --> 00:01:49,970 include("inc/header.php") and close our PHP tag. 22 00:01:49,970 --> 00:01:54,766 Then we need the div for the page content as well as the title of the page. 23 00:01:59,204 --> 00:02:04,952 H1 tag, Full Catalog. 24 00:02:07,150 --> 00:02:09,230 Then we'll end this file by including the footer as well. 25 00:02:10,660 --> 00:02:17,871 Open our PHP, include('inc/footer.php"). 26 00:02:20,223 --> 00:02:24,970 Our books, movies, and music pages will all work essentially the same way. 27 00:02:24,970 --> 00:02:28,410 They will display data about our items in our catalog. 28 00:02:28,410 --> 00:02:32,160 We used include files for the header and footer to share code, but for 29 00:02:32,160 --> 00:02:34,750 this file we're going to use the same page and 30 00:02:34,750 --> 00:02:38,880 change the content slightly based on what page is be shown. 31 00:02:38,880 --> 00:02:43,240 This is the same technique we'll be using to show an individual title for 32 00:02:43,240 --> 00:02:47,680 each page even though our title tag is in a single header.php file. 33 00:02:49,150 --> 00:02:50,320 We'll be adding the code for 34 00:02:50,320 --> 00:02:53,280 differentiating these pages In another video. 35 00:02:53,280 --> 00:02:57,140 But for now, let's update the menu so that books, movies and 36 00:02:57,140 --> 00:03:00,680 music all link to our new catalog page. 37 00:03:00,680 --> 00:03:05,380 As we do this, you'll be able to see how our technique of including files 38 00:03:05,380 --> 00:03:09,320 already makes our code easier to maintain as our gallery grows. 39 00:03:09,320 --> 00:03:12,310 We need to update the link, on three different webpages. 40 00:03:12,310 --> 00:03:16,370 But since all three include the same header.php file, 41 00:03:16,370 --> 00:03:18,720 we only have to make that change in one place.