/** * Returns the root for the content file * * @return string */ public function textfile($template = null, $lang = null) { if (is_null($template)) { $template = $this->intendedTemplate(); } if (is_null($lang)) { $lang = $this->site->language->code; } return textfile($this->diruri(), $template, $lang); }
/** * Creates a new page object * * @param string $uri * @param string $template * @param array $data */ public static function create($uri, $template, $data = array()) { if (!is_string($template) or empty($template)) { throw new Exception('Please pass a valid template name as second argument'); } // try to create the new directory $uri = static::createDirectory($uri); // create the path for the textfile $file = textfile($uri, $template); // try to store the data in the text file if (!data::write($file, $data, 'kd')) { throw new Exception('The page file could not be created'); } // get the new page object $page = page($uri); if (!is_a($page, 'Page')) { throw new Exception('The new page object could not be found'); } kirby::instance()->cache()->flush(); return $page; }