PagesController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. namespace app\controllers;
  9. /**
  10. * This controller is used for serving static pages by name, which are located in the `/views/pages`
  11. * folder.
  12. *
  13. * A Lithium application's default routing provides for automatically routing and rendering
  14. * static pages using this controller. The default route (`/`) will render the `home` template, as
  15. * specified in the `view()` action.
  16. *
  17. * Additionally, any other static templates in `/views/pages` can be called by name in the URL. For
  18. * example, browsing to `/pages/about` will render `/views/pages/about.html.php`, if it exists.
  19. *
  20. * Templates can be nested within directories as well, which will automatically be accounted for.
  21. * For example, browsing to `/pages/about/company` will render
  22. * `/views/pages/about/company.html.php`.
  23. */
  24. class PagesController extends \lithium\action\Controller {
  25. public function view() {
  26. $options = array();
  27. $path = func_get_args();
  28. if (!$path || $path === array('home')) {
  29. $path = array('home');
  30. $options['compiler'] = array('fallback' => true);
  31. }
  32. $options['template'] = join('/', $path);
  33. return $this->render($options);
  34. }
  35. }
  36. ?>