}); // For single article // Usage => Morfy::runAction('item_nextprev'); Morfy::addAction('item_nextprev', function () use($nextprev_config, $nextprev_template) { // Get current URI segments $path = Url::getUriSegments(); array_pop($path); $path = implode('/', $path); // Get all posts $all_pages = Morfy::getPages($path, 'date', 'DESC', array('404', 'index')); // Count total posts $total_pages = count($all_pages); // Get current page path $current_path = Url::getUriString(); // Get current page data $current_page = Morfy::getPage($current_path); // Testing... // echo $current_page['date']; // Find next and previous link from current page $prev_page = $next_page = false; for ($i = 0; $i < $total_pages; $i++) { if ($current_page['date'] == $all_pages[$i]['date']) { $prev_page = isset($all_pages[$i - 1]['url']) && !empty($all_pages[$i - 1]['url']) ? $all_pages[$i - 1]['url'] : false; $next_page = isset($all_pages[$i + 1]['url']) && !empty($all_pages[$i + 1]['url']) ? $all_pages[$i + 1]['url'] : false; } } unset($all_pages); // Pagination $nextprev_template->display('nav.tpl', array('config' => $nextprev_config, 'current' => 1, 'total' => $total_pages, 'prev' => $prev_page, 'next' => $next_page)); }); // Conditional action between `index_nextprev` and `item_nextprev`
<?php /** * Morfy Feed Plugin * * (c) Romanenko Sergey / Awilum <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ if (Url::getUriSegment(0) == 'rss') { Morfy::addAction('before_render', function () { $fenom = Fenom::factory(PLUGINS_PATH . '/feed/templates/', CACHE_PATH . '/fenom/', Morfy::$fenom); $fenom->setOptions(array("strip" => false)); Response::status(200); Request::setHeaders('Content-Type: text/xml; charset=utf-8'); $fenom->display('rss.tpl', array('page' => Morfy::getPage(Morfy::$plugins['feed']['page']), 'pages' => Morfy::getPages(Morfy::$plugins['feed']['page'], 'date', 'DESC', array('404')))); Request::shutdown(); }); }