function __invoke($method, $path, $cms) { $this->cms = $cms = $this; // include prepend PHP file first is_file($php = \dir\content($path . '/index.php')) ? include_once $php : null || is_file($php = \dir\content($path . '.php')) ? include_once $php : null; // search page (html, md, latte, phtml) $this->page = Page::fromPath(\dir\content() . '/' . $path, (array) config()->meta); // include functions.php from $path and working directory is_file($php = \dir\content($path . '/functions.php')) ? include_once $php : null; is_file(getcwd() . '/functions.php') ? include_once getcwd() . '/functions.php' : null; print $this->page ? $this->render() : \route\error(404, $method, $path, $this); }
/** * Return pages directory. * * @param null|string $path * @return string */ function content($path = null) { $content = isset(config()->content) ? config()->content : (config()->content = getcwd() . '/pages/'); return realpath($content . '/' . $path); }