From 0fca7a31537a2b5dd06116b794eb38521391c71a Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 9 Dec 2012 18:41:14 +0200 Subject: [PATCH] PagesPlugin: add ability to get content for specific page. --- plugins/box/pages/pages.plugin.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/box/pages/pages.plugin.php b/plugins/box/pages/pages.plugin.php index b56649c..726b51d 100644 --- a/plugins/box/pages/pages.plugin.php +++ b/plugins/box/pages/pages.plugin.php @@ -256,8 +256,28 @@ * * @return string */ - public static function content() { - return Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . Pages::$page['id'] . '.page.txt')); + public static function content($slug = '') { + + if ( ! empty($slug)) { + + $page = Table::factory('pages')->select('[slug="'.$slug.'"]', null); + + if ( ! empty($page)) { + + $content = Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . $page['id'] . '.page.txt')); + + $content = Filter::apply('content', $content); + + return $content; + + } else { + return ''; + } + + } else { + return Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . Pages::$page['id'] . '.page.txt')); + } + } @@ -317,7 +337,7 @@ /** * Page class */ - class Page extends Pages { + class Page extends Pages { /**