1 00:00:01,390 --> 00:00:05,040 Currently, the collection class is abstract and 2 00:00:05,040 --> 00:00:07,830 it implements the CollectionInterface. 3 00:00:07,830 --> 00:00:12,610 All methods from the interface are being implemented in the collection class. 4 00:00:12,610 --> 00:00:15,740 Let's add one more method to that interface. 5 00:00:15,740 --> 00:00:20,390 We'll call this public function getTitle. 6 00:00:22,540 --> 00:00:23,740 Now let's preview our site again. 7 00:00:25,470 --> 00:00:28,440 We get another error like we've seen before because we have not 8 00:00:28,440 --> 00:00:30,510 implemented our required method. 9 00:00:30,510 --> 00:00:32,980 But let's take a closer look at that error. 10 00:00:32,980 --> 00:00:38,550 First, notice that the error is on the post class, not on the collection class. 11 00:00:39,790 --> 00:00:42,550 The next part of the error explains why. 12 00:00:42,550 --> 00:00:46,310 The abstract method must either be implemented or 13 00:00:46,310 --> 00:00:50,240 the class itself may be declared abstract. 14 00:00:50,240 --> 00:00:52,950 Because the collection class is abstract. 15 00:00:52,950 --> 00:00:55,850 And therefore cannot be instantiated, 16 00:00:55,850 --> 00:01:00,620 it is not required to implement all the required methods itself. 17 00:01:00,620 --> 00:01:05,830 Instead, this requirement is passed to any non-abstract class, 18 00:01:05,830 --> 00:01:07,920 extending the collection class. 19 00:01:07,920 --> 00:01:09,995 Let's add this method to the post class. 20 00:01:20,931 --> 00:01:23,266 Public function getTitle. 21 00:01:27,146 --> 00:01:32,873 First, if this count is equal to 1, 22 00:01:37,494 --> 00:01:41,120 This means that we're on a single post page. 23 00:01:41,120 --> 00:01:44,566 If we're on a single post page, we want to return the current title. 24 00:01:50,232 --> 00:01:56,575 If we make it past this return, we'll simply return Latest Posts. 25 00:01:59,040 --> 00:02:00,730 Let's clean up our pages. 26 00:02:00,730 --> 00:02:08,830 In header.php, in our views folder, We used the title twice. 27 00:02:08,830 --> 00:02:14,706 Let's replace those with this new method instead, content getTitle. 28 00:02:27,310 --> 00:02:29,919 Now we can remove the title from the index page. 29 00:02:43,683 --> 00:02:49,340 Since we don't need to set the title, we can make this a single if statement. 30 00:02:49,340 --> 00:02:55,617 So, if our content is not set or 31 00:02:55,617 --> 00:03:04,075 the content count is not equal to 1, or, 32 00:03:06,796 --> 00:03:13,460 The content current status does not equal published. 33 00:03:15,840 --> 00:03:17,980 Then we will select all posts. 34 00:03:17,980 --> 00:03:18,516 Once again, 35 00:03:18,516 --> 00:03:21,847 let's preview the site to make sure everything is still functioning properly. 36 00:03:27,199 --> 00:03:28,440 Looks good. 37 00:03:28,440 --> 00:03:31,490 We're ready to add a second content type for 38 00:03:31,490 --> 00:03:36,120 pages by extending a second child of the collection class.