03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

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

File-Based CMS 338<br />

169 }<br />

170 }<br />

.<br />

This file should be saved as app/controllers/PageController.php.<br />

The constructor method accepts the same injected dependencies as our layout controller did. We<br />

also define similar custom validation rules to check the names of files we want to save.<br />

The addAction() method differs slightly in that we load the existing layout files so that we can<br />

designate the layout for each page. We also add this (and the route parameter) to the metadata<br />

saved to the page file.<br />

The editAction() method loads the route and layout parameters (in addition to the other fields) and<br />

passes them to the edit page template, where they will be used to populate the new fields.<br />

1 <br />

5 <br />

6 <br />

7 <br />

12 Toggle navigation<br />

13 <br />

14 <br />

15 <br />

16 <br />

17 <br />

18 <br />

19 <br />

20 <br />

21 <br />

22 Layouts<br />

23 <br />

24 <br />

25 <br />

26

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

Saved successfully!

Ooh no, something went wrong!