1 2014-02-10 16:38:33 (edited by tovic 2014-02-21 08:37:03)

Topic: Blog Pagination (Next/Previous) for Morfy CMS

Index Page

http://i61.tinypic.com/2pysz6p.png

Item Page

http://i57.tinypic.com/153tob9.png

Installation

1. Download and extract this file, put the nextprev folder with its contents in plugins folder.

2. Update you config.php file:

<?php
    return array(
        ...
        ...
        ...
        'plugins' => array(
            'markdown',
            'sitemap',
            'nextprev' // <= Activation
        ),
        'nextprev_config' => array( // <= Configuration
            'param' => 'page', // <= Page parameter name in URL
            'limit' => 5, // <= Number of posts to display per page
            'classes' => array( // <= List of item's HTML classes
                'page_item' => 'page',
                'nav' => 'pager',
                'nav_prev' => 'previous',
                'nav_next' => 'next',
                'nav_disabled' => 'disabled'
            ),
            'labels' => array( // <= List of item's readable text or labels
                'nav_prev' => '← Previous',
                'nav_next' => 'Next →',
                'not_found' => '<div class="alert alert-danger"><p>Not found.</p></div>'
            )
        )
    );

Updating Template File

The plugin includes index_nextprev for posts listing page and item_nextprev for individual page.

1. For blog.html, all posts loop will be replaced by the plugin:

<?php include 'header.html' ?>
<?php include 'navbar.html' ?>
<div class="container">
    <?php Morfy::factory()->runAction('theme_content_before'); ?>
    <?php Morfy::factory()->runAction('index_nextprev'); ?>
    <?php Morfy::factory()->runAction('theme_content_after'); ?>
</div>
<?php include 'footer.html' ?>

2. For blog_post.html, the plugin will only return as a next/previous navigation:

<?php include 'header.html' ?>
<?php include 'navbar.html' ?>
<div class="container">
    <?php Morfy::factory()->runAction('theme_content_before'); ?>
    <h3><?php echo $page['title']; ?></h3>
    <p>Posted on <?php echo $page['date']; ?></p>
    <div><?php echo $page['content']; ?></div>
    <?php Morfy::factory()->runAction('item_nextprev'); ?>
    <?php Morfy::factory()->runAction('theme_content_after'); ?>
    <hr>
</div>
<?php include 'footer.html' ?>
XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

2 2014-02-11 00:43:33 (edited by tovic 2014-02-11 00:44:57)

Re: Blog Pagination (Next/Previous) for Morfy CMS

There is a little update. Please re-download the plugin. Still trying to deal with pages that have more than one subpage. No error displayed, but all of the items, however depth the folders, are displayed within a single array if called with Morfy::factory()->getPages()

There’s no API method that can be used to retreive pages (file only) that’s only in the current folder, exluding the subfolder.

In CSS, you may know this kind of selector:

#root > folder > .file
#root
  -  folder
  -  -  i'll be selected
  -  -  folder
  -  -  -  but i'll not
  -  -  i'll be selected
  -  -  i'll be selected

We need that API.

XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

Re: Blog Pagination (Next/Previous) for Morfy CMS

good job! big_smile

I'm not like them but I can pretend.

4 (edited by tovic 2014-02-12 01:13:09)

Re: Blog Pagination (Next/Previous) for Morfy CMS

Aryandhani wrote:

good job! big_smile

Hi thanks! I also already update the plugin to follow Bootstrap’s pagination markup and commented out the stylesheet hooks by default as you suggest. So users no longer need to append the extra stylesheet for this.

XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

Re: Blog Pagination (Next/Previous) for Morfy CMS

My mistake. A little bug fix:

Replace this code in index_nextprev

<a href="' . rtrim(Morfy::$config['site_url'], '/') . '/' . $path . '/' . $post['slug'] . '">

to this:

<a href="' . $post['url'] . '">

Or just re-download the file.

XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

Re: Blog Pagination (Next/Previous) for Morfy CMS

ok. I've was tried it. but, there is something wrong in index_nextprev on my themes. This:

echo $post['description'] ? '<div>' . $post['description'] . '</div>' : "";

Short content not show up. but when I replace it with this (content_short):

echo $post['content_short'] ? '<div>' . $post['content_short'] . '</div>' : "";

successfully. How could that be?

I'm not like them but I can pretend.

7 2014-02-14 00:20:40 (edited by tovic 2014-02-14 00:23:00)

Re: Blog Pagination (Next/Previous) for Morfy CMS

Aryandhani wrote:

ok. I've was tried it. but, there is something wrong in index_nextprev on my themes. This:

echo $post['description'] ? '<div>' . $post['description'] . '</div>' : "";

Short content not show up. but when I replace it with this (content_short):

echo $post['content_short'] ? '<div>' . $post['content_short'] . '</div>' : "";

successfully. How could that be?

That’s come from different field. $post['description'] come from here:

Title: Welcome
Description: Some description here. // <= this
Keywords: key, words
Author: Awilum
Date: 2013-12-31 00:00:00
Tags: tag1, tag2
Robots: noindex, nofollow
Template: index

Usually used to fill the <meta name="description"> content for SEO purpose. While the $post['content_short'] come from $post['content'] before {cut}

I will be your post description. // <= this
{cut}
Vitae, velit, temporibus sequi mollitia dolorem voluptatibus assumenda et cumque soluta laudantium commodi odit cupiditate eos nobis quisquam obcaecati vero rerum ut.

You can create a simple conditional function to make sure the post description become visible if available, if not, show the content short:

if(strlen($post['description']) > 0) {
    echo '<div>' . $post['description'] . '</div>';
} elseif (strlen($post['content_short']) > 0) {
    echo '<div>' . $post['content_short'] . '</div>';
} else {
    echo '<div>Description not available.</div>';
}
XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

Re: Blog Pagination (Next/Previous) for Morfy CMS

ok thanks

I'm not like them but I can pretend.

Re: Blog Pagination (Next/Previous) for Morfy CMS

can be pagination for each template separately as exemplified below;

blog template

<?php include 'header.html' ?>
<?php include 'navbar.html' ?>
<div class="container">
    <?php Morfy::factory()->runAction('theme_content_before'); ?>
      <?php
            //  Morfy::factory()->getPages($url,$order_by,$order_type,$ignore,$limit);
            // $url  is a folder of posts
            $url = CONTENT_PATH . '/blog/';
            // $order_by is a order like date or title 
            $order_by = 'date';
            // $order_type is a order type  like ASC or DESC
            $order_type =   'DESC';
            // $ignore  = array of files to ignore
            $ignore =  array('404','index');
            // $limit is a number of posts
            $limit = 2;
            $posts = Morfy::factory()->getPages($url,$order_by, $order_type,$ignore,$limit);
            foreach($posts as $post) {
                // use default image if not write Thumbnail 
                $thumbnail =  ($post['thumbnail']) ? $post['thumbnail'] : $config['Site_url'].'public/images/default.jpg';
                echo '<h3><a href="'.$config['site_url'].'/blog/'.$post['slug'].'">'.$post['title'].'</a></h3>                
                <p>Posted on '.$post['date'].'</p>
                <div class="tumb">
                    <img src="'.$thumbnail.'" alt="'.$post['title'].'">
                </div>
                <div>'.$post['content_short'].'</div>';
            }
    ?>
    <?php Morfy::factory()->runAction('index_nextprev'); ?>
    <?php Morfy::factory()->runAction('theme_content_after'); ?>
</div>
<?php include 'footer.html' ?>

news template

<?php include 'header.html' ?>
<?php include 'navbar.html' ?>
<div class="container">
    <?php Morfy::factory()->runAction('theme_content_before'); ?>
      <?php
            //  Morfy::factory()->getPages($url,$order_by,$order_type,$ignore,$limit);
            // $url  is a folder of posts
            $url = CONTENT_PATH . '/news/';
            // $order_by is a order like date or title 
            $order_by = 'date';
            // $order_type is a order type  like ASC or DESC
            $order_type =   'DESC';
            // $ignore  = array of files to ignore
            $ignore =  array('404','index');
            // $limit is a number of posts
            $limit = 2;
            $posts = Morfy::factory()->getPages($url,$order_by, $order_type,$ignore,$limit);
            foreach($posts as $post) {
                // use default image if not write Thumbnail 
                $thumbnail =  ($post['thumbnail']) ? $post['thumbnail'] : $config['Site_url'].'public/images/default.jpg';
                echo '<h3><a href="'.$config['site_url'].'/news/'.$post['slug'].'">'.$post['title'].'</a></h3>                
                <p>Posted on '.$post['date'].'</p>
                <div class="tumb">
                    <img src="'.$thumbnail.'" alt="'.$post['title'].'">
                </div>
                <div>'.$post['content_short'].'</div>';
            }
    ?>
    <?php Morfy::factory()->runAction('index_nextprev'); ?>
    <?php Morfy::factory()->runAction('theme_content_after'); ?>
</div>
<?php include 'footer.html' ?>

Re: Blog Pagination (Next/Previous) for Morfy CMS

Try jeje i think yes

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

Re: Blog Pagination (Next/Previous) for Morfy CMS

nakome wrote:

Try jeje i think yes

?

Re: Blog Pagination (Next/Previous) for Morfy CMS

Yes, the plugin will automatically detect the current folder via URL path.

Example:

  • hxxp://latitudu.com/notes/morfy-cms (blog page)

  • hxxp://latitudu.com/notes/morfy-cms/plugins (plugins page)

  • hxxp://latitudu.com/notes/nursing (another blog page)

Note: Here I put the blog pagination in blog.html, so all of the page above only use blog.html template. But again, It works only by detecting folder names from URL, so it will work if you put them in news.html template for example as an alternative for blog.html or has the same behavior with the blog.html template.

XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

13 (edited by tovic 2015-02-20 12:56:52)

Re: Blog Pagination (Next/Previous) for Morfy CMS

Update:

Oh, so you want to make the blog pagination separated from the posts list. Hm, you will need to modify the source code yourself.

Put the content of the plugin definition from here to here to replace the <?php Morfy::factory()->runAction('index_nextprev'); ?> line in your template.

XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

Re: Blog Pagination (Next/Previous) for Morfy CMS

tovic wrote:

Update:

Oh, so you want to make the blog pagination separated from the posts list. Hm, you will need to modify the source code yourself.

Put the content of the plugin definition from here to here to replace the <?php Morfy::factory()->runAction('index_nextprev'); ?> line in your template.


<?php
/**
 * Next & Previous Navigation for Morfy CMS
 *
 * @package Morfy
 * @subpackage Plugins
 * @author Taufik Nurrohman <http://latitudu.com>
 * @copyright 2014 Romanenko Sergey / Awilum
 * @version 1.0.4
 *
 */
// Include `shell.css` in header
// Uncomment the hook function below if you are not using Bootstrap.
// Morfy::factory()->addAction('theme_header', function() {
//     echo '<link href="' . Morfy::$config['site_url'] . '/plugins/nextprev/lib/css/shell.css" rel="stylesheet">' . "\n";
// });
// For posts listing page
// Usage => Morfy::factory()->runAction('index_nextprev');
Morfy::factory()->addAction('index_nextprev', function() {
    // Configuration data
    $config = Morfy::$config['nextprev_config'];
    // Get current URI segments
    $path = Morfy::factory()->getUriSegments();
    $path = implode('/', $path);
    // Number of posts to display per page request
    $per_page = isset($config['limit']) ? $config['limit'] : 5;
    // Get all posts
    $all_posts = Morfy::factory()->getPages(CONTENT_PATH . '/' . $path . '/', 'date', 'DESC', array('404', 'index'));
    // Calculate total pages
    $total_pages = ceil(count($all_posts) / $per_page);
    // Get current page offset
    $current_page = isset($_GET[$config['param']]) ? $_GET[$config['param']] : 1;
    // Split all posts into chunks
    $posts = is_array($all_posts) ? array_chunk($all_posts, $per_page) : array();
    // Build the pagination
    $html  = '<ul class="' . $config['classes']['nav'] . '">';
    $html .= $current_page > 1 ? '<li class="' . $config['classes']['nav_prev'] . '"><a href="?' . $config['param'] . '=' . ($current_page - 1) . '">' . $config['labels']['nav_prev'] . '</a></li>' : '<li class="' . $config['classes']['nav_prev'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_prev'] . '</span></li>';
    $html .= $current_page < $total_pages ? ' <li class="' . $config['classes']['nav_next'] . '"><a href="?' . $config['param'] . '=' . ($current_page + 1) . '">' . $config['labels']['nav_next'] . '</a></li>' : ' <li class="' . $config['classes']['nav_next'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_next'] . '</span></li>';
    $html .= '</ul>';
    echo $html;
});
// For single article
// Usage => Morfy::factory()->runAction('item_nextprev');
Morfy::factory()->addAction('item_nextprev', function() {
    // Configuration data
    $config = Morfy::$config['nextprev_config'];
    // Get current URI segments
    $path = Morfy::factory()->getUriSegments();
    array_pop($path);
    $path = implode('/', $path);
    // Get all posts
    $all_posts = Morfy::factory()->getPages(CONTENT_PATH . '/' . $path . '/', 'date', 'DESC', array('404', 'index'));
    // Count total posts
    $total_posts = count($all_posts);
    // Get current page URL
    $current_url = Morfy::factory()->getUrl();
    // Get current page data
    $current_page = Morfy::factory()->getPage($current_url);
    // Testing...
    // echo $current_page['date'];
    // Find next and previous link from current page
    $prev_page = $next_page = null;
    for($i = 0; $i < $total_posts; $i++) {
        if($current_page['date'] == $all_posts[$i]['date']) {
            $prev_page = isset($all_posts[$i - 1]['url']) && ! empty($all_posts[$i - 1]['url']) ? $all_posts[$i - 1]['url'] : null;
            $next_page = isset($all_posts[$i + 1]['url']) && ! empty($all_posts[$i + 1]['url']) ? $all_posts[$i + 1]['url'] : null;
        }
    }
    // Build the pagination
    $html  = '<ul class="' . $config['classes']['nav'] . '">';
    $html .= $prev_page !== null ? '<li class="' . $config['classes']['nav_prev'] . '"><a href="' . $prev_page . '">' . $config['labels']['nav_prev'] . '</a></li>' : '<li class="' . $config['classes']['nav_prev'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_prev'] . '</span></li>';
    $html .= $next_page !== null ? ' <li class="' . $config['classes']['nav_next'] . '"><a href="' . $next_page . '">' . $config['labels']['nav_next'] . '</a>' : ' <li class="' . $config['classes']['nav_next'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_next'] . '</span></li>';
    $html .= '</ul>';
    echo $html;
});

this is right;

15 2015-02-21 06:03:42 (edited by tovic 2015-02-21 06:04:24)

Re: Blog Pagination (Next/Previous) for Morfy CMS

Something like this:

<?php include 'header.html' ?>
<?php include 'navbar.html' ?>
<div class="container">
    <?php Morfy::factory()->runAction('theme_content_before'); ?>
    <?php
    // Configuration data
    $config = Morfy::$config['nextprev_config'];
    // Get current URI segments
    $path = Morfy::factory()->getUriSegments();
    $path = implode('/', $path);
    // Number of posts to display per page request
    $per_page = isset($config['limit']) ? $config['limit'] : 5;
    // Get all posts
    $all_posts = Morfy::factory()->getPages(CONTENT_PATH . '/' . $path . '/', 'date', 'DESC', array('404', 'index'));
    // Calculate total pages
    $total_pages = ceil(count($all_posts) / $per_page);
    // Get current page offset
    $current_page = isset($_GET[$config['param']]) ? $_GET[$config['param']] : 1;
    // Split all posts into chunks
    $posts = is_array($all_posts) ? array_chunk($all_posts, $per_page) : array();
    // Posts loop
    if(isset($posts[$current_page - 1]) && ! empty($posts[$current_page - 1])) {
        foreach($posts[$current_page - 1] as $post) {
            echo '<div class="' . $config['classes']['page_item'] . '">';
            echo $post['title'] ? '<h3><a href="' . $post['url'] . '">' . $post['title'] . '</a></h3>' : "";
            echo $post['date'] ? '<p><em><strong>Published on:</strong> ' . $post['date'] . '</em></p>' : "";
            if(strlen($post['description']) > 0) {
                echo '<p>' . $post['description'] . '</p>';
            } elseif(strlen($post['content_short']) > 0) {
                echo '<p>' . $post['content_short'] . '</p>';
            }
            echo '</div>';
        }
    } else {
        echo '<div class="' . $config['classes']['page_item'] . '">' . $config['labels']['not_found'] . '</div>';
    }
    // Build the pagination
    $html  = '<ul class="' . $config['classes']['nav'] . '">';
    $html .= $current_page > 1 ? '<li class="' . $config['classes']['nav_prev'] . '"><a href="?' . $config['param'] . '=' . ($current_page - 1) . '">' . $config['labels']['nav_prev'] . '</a></li>' : '<li class="' . $config['classes']['nav_prev'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_prev'] . '</span></li>';
    $html .= $current_page < $total_pages ? ' <li class="' . $config['classes']['nav_next'] . '"><a href="?' . $config['param'] . '=' . ($current_page + 1) . '">' . $config['labels']['nav_next'] . '</a></li>' : ' <li class="' . $config['classes']['nav_next'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_next'] . '</span></li>';
    $html .= '</ul>';
    echo $html;
    ?>
    <?php Morfy::factory()->runAction('theme_content_after'); ?>
</div>
<?php include 'footer.html' ?>
XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

16 2015-02-21 09:16:19

Re: Blog Pagination (Next/Previous) for Morfy CMS

Thank you!
there is an error <?php Morfy::factory()->runAction('item_nextprev'); ?> when we go to the last page after not going back sad

17 2015-02-21 15:56:11

Re: Blog Pagination (Next/Previous) for Morfy CMS

Really? It should be faded to a gray button on the last/first page.

XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

Re: Blog Pagination (Next/Previous) for Morfy CMS

is ok! I just had to post all the same date so they do not go back!
I changed the dates and it works fine!

Re: Blog Pagination (Next/Previous) for Morfy CMS

Just advice: http://forum.monstra.org/topic/550/prop … t-for-post

XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

Re: Blog Pagination (Next/Previous) for Morfy CMS

@tonic
how do I replace the parameters in config.php

'nextprev_config' => array( // <= Configuration
            'param' => 'page', // <= Page parameter name in URL
            'limit' => 5, // <= Number of posts to display per page
            'classes' => array( // <= List of item's HTML classes
                'page_item' => 'page',
                'nav' => 'pager',
                'nav_prev' => 'previous',
                'nav_next' => 'next',
                'nav_disabled' => 'disabled'
            ),
            'labels' => array( // <= List of item's readable text or labels
                'nav_prev' => '← Previous',
                'nav_next' => 'Next →',
                'not_found' => '<div class="alert alert-danger"><p>Not found.</p></div>'
            )
        )

only exist in the file nextprev.php ?

21 2015-03-01 14:39:51

Re: Blog Pagination (Next/Previous) for Morfy CMS

I don’t get it.

XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

22 (edited by dextra 2015-03-01 16:02:31)

Re: Blog Pagination (Next/Previous) for Morfy CMS

@tovic

I mean something like this

    // Build the pagination
    $html  = '<ul class="' . $config['classes']['nav'] . '">';
    $html .= $current_page > 1 ? '<li class="' . $config['classes']['nav_prev'] . '"><a href="?' . $config['param'] . '=' . ($current_page - 1) . '">' . $config['labels']['nav_prev'] . '</a></li>' : '<li class="' . $config['classes']['nav_prev'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_prev'] . '</span></li>';
    $html .= $current_page < $total_pages ? ' <li class="' . $config['classes']['nav_next'] . '"><a href="?' . $config['param'] . '=' . ($current_page + 1) . '">' . $config['labels']['nav_next'] . '</a></li>' : ' <li class="' . $config['classes']['nav_next'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_next'] . '</span></li>';
    $html .= '</ul>';
    // Build the pagination
    $html  = '<ul class="pager">';
    $html .= $current_page > 1 ? '<li class="previous"><a href="?page=' . ($current_page - 1) . '">← Previous</a></li>' : '<li class="previous disabled"><span>← Previous</span></li>';
    $html .= $current_page < $total_pages ? ' <li class="next"><a href="?page=' . ($current_page + 1) . '">Next →</a></li>' : ' <li class="next disabled'"><span>Next →</span></li>';
    $html .= '</ul>';

I mean to have no parameters config.php

Re: Blog Pagination (Next/Previous) for Morfy CMS

Replace this line:

// Configuration data
$config = Morfy::$config['nextprev_config'];

with the configuration data:

// Configuration data
$config = array( // <= Configuration
    'param' => 'page', // <= Page parameter name in URL
    'limit' => 5, // <= Number of posts to display per page
    ...
);
XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website

Re: Blog Pagination (Next/Previous) for Morfy CMS

now

<?php
    return array(
        ...
        ...
        ...
        'plugins' => array(
            'markdown',
            'sitemap',
            'nextprev' // <= Activation
        ),
        'nextprev_config' => array( // <= Configuration
            'param' => 'page', // <= Page parameter name in URL
            'limit' => 5, // <= Number of posts to display per page
            'classes' => array( // <= List of item's HTML classes
                'page_item' => 'page',
                'nav' => 'pager',
                'nav_prev' => 'previous',
                'nav_next' => 'next',
                'nav_disabled' => 'disabled'
            ),
            'labels' => array( // <= List of item's readable text or labels
                'nav_prev' => '← Previous',
                'nav_next' => 'Next →',
                'not_found' => '<div class="alert alert-danger"><p>Not found.</p></div>'
            )
        )
    );

template news.html

<?php include 'header.html' ?>
<?php include 'navbar.html' ?>
<div class="container">
    <?php Morfy::factory()->runAction('theme_content_before'); ?>
    <?php
    // Configuration data
    $config = Morfy::$config['nextprev_config'];
    // Get current URI segments
    $path = Morfy::factory()->getUriSegments();
    $path = implode('/', $path);
    // Number of posts to display per page request
    $per_page = isset($config['limit']) ? $config['limit'] : 5;
    // Get all posts
    $all_posts = Morfy::factory()->getPages(CONTENT_PATH . '/' . $path . '/', 'date', 'DESC', array('404', 'index'));
    // Calculate total pages
    $total_pages = ceil(count($all_posts) / $per_page);
    // Get current page offset
    $current_page = isset($_GET[$config['param']]) ? $_GET[$config['param']] : 1;
    // Split all posts into chunks
    $posts = is_array($all_posts) ? array_chunk($all_posts, $per_page) : array();
    // Posts loop
    if(isset($posts[$current_page - 1]) && ! empty($posts[$current_page - 1])) {
        foreach($posts[$current_page - 1] as $post) {
            echo '<div class="' . $config['classes']['page_item'] . '">';
            echo $post['title'] ? '<h3><a href="' . $post['url'] . '">' . $post['title'] . '</a></h3>' : "";
            echo $post['date'] ? '<p><em><strong>Published on:</strong> ' . $post['date'] . '</em></p>' : "";
            if(strlen($post['description']) > 0) {
                echo '<p>' . $post['description'] . '</p>';
            } elseif(strlen($post['content_short']) > 0) {
                echo '<p>' . $post['content_short'] . '</p>';
            }
            echo '</div>';
        }
    } else {
        echo '<div class="' . $config['classes']['page_item'] . '">' . $config['labels']['not_found'] . '</div>';
    }
    // Build the pagination
    $html  = '<ul class="' . $config['classes']['nav'] . '">';
    $html .= $current_page > 1 ? '<li class="' . $config['classes']['nav_prev'] . '"><a href="?' . $config['param'] . '=' . ($current_page - 1) . '">' . $config['labels']['nav_prev'] . '</a></li>' : '<li class="' . $config['classes']['nav_prev'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_prev'] . '</span></li>';
    $html .= $current_page < $total_pages ? ' <li class="' . $config['classes']['nav_next'] . '"><a href="?' . $config['param'] . '=' . ($current_page + 1) . '">' . $config['labels']['nav_next'] . '</a></li>' : ' <li class="' . $config['classes']['nav_next'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_next'] . '</span></li>';
    $html .= '</ul>';
    echo $html;
    ?>
    <?php Morfy::factory()->runAction('theme_content_after'); ?>
</div>
<?php include 'footer.html' ?>

code nextprev.php

<?php
/**
 * Next & Previous Navigation for Morfy CMS
 *
 * @package Morfy
 * @subpackage Plugins
 * @author Taufik Nurrohman <http://latitudu.com>
 * @copyright 2014 Romanenko Sergey / Awilum
 * @version 1.0.4
 *
 */
// Include `shell.css` in header
// Uncomment the hook function below if you are not using Bootstrap.
// Morfy::factory()->addAction('theme_header', function() {
//     echo '<link href="' . Morfy::$config['site_url'] . '/plugins/nextprev/lib/css/shell.css" rel="stylesheet">' . "\n";
// });
// For posts listing page
// Usage => Morfy::factory()->runAction('index_nextprev');
Morfy::factory()->addAction('index_nextprev', function() {
    // Configuration data
    $config = Morfy::$config['nextprev_config'];
    // Get current URI segments
    $path = Morfy::factory()->getUriSegments();
    $path = implode('/', $path);
    // Number of posts to display per page request
    $per_page = isset($config['limit']) ? $config['limit'] : 5;
    // Get all posts
    $all_posts = Morfy::factory()->getPages(CONTENT_PATH . '/' . $path . '/', 'date', 'DESC', array('404', 'index'));
    // Calculate total pages
    $total_pages = ceil(count($all_posts) / $per_page);
    // Get current page offset
    $current_page = isset($_GET[$config['param']]) ? $_GET[$config['param']] : 1;
    // Split all posts into chunks
    $posts = is_array($all_posts) ? array_chunk($all_posts, $per_page) : array();
    // Posts loop
    if(isset($posts[$current_page - 1]) && ! empty($posts[$current_page - 1])) {
        foreach($posts[$current_page - 1] as $post) {
            echo '<div class="' . $config['classes']['page_item'] . '">';
            echo $post['title'] ? '<h3><a href="' . $post['url'] . '">' . $post['title'] . '</a></h3>' : "";
            echo $post['date'] ? '<p><em><strong>Published on:</strong> ' . $post['date'] . '</em></p>' : "";
            if(strlen($post['description']) > 0) {
                echo '<p>' . $post['description'] . '</p>';
            } elseif(strlen($post['content_short']) > 0) {
                echo '<p>' . $post['content_short'] . '</p>';
            }
            echo '</div>';
        }
    } else {
        echo '<div class="' . $config['classes']['page_item'] . '">' . $config['labels']['not_found'] . '</div>';
    }
    // Build the pagination
    $html  = '<ul class="' . $config['classes']['nav'] . '">';
    $html .= $current_page > 1 ? '<li class="' . $config['classes']['nav_prev'] . '"><a href="?' . $config['param'] . '=' . ($current_page - 1) . '">' . $config['labels']['nav_prev'] . '</a></li>' : '<li class="' . $config['classes']['nav_prev'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_prev'] . '</span></li>';
    $html .= $current_page < $total_pages ? ' <li class="' . $config['classes']['nav_next'] . '"><a href="?' . $config['param'] . '=' . ($current_page + 1) . '">' . $config['labels']['nav_next'] . '</a></li>' : ' <li class="' . $config['classes']['nav_next'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_next'] . '</span></li>';
    $html .= '</ul>';
    echo $html;
});
// For single article
// Usage => Morfy::factory()->runAction('item_nextprev');
Morfy::factory()->addAction('item_nextprev', function() {
    // Configuration data
    $config = Morfy::$config['nextprev_config'];
    // Get current URI segments
    $path = Morfy::factory()->getUriSegments();
    array_pop($path);
    $path = implode('/', $path);
    // Get all posts
    $all_posts = Morfy::factory()->getPages(CONTENT_PATH . '/' . $path . '/', 'date', 'DESC', array('404', 'index'));
    // Count total posts
    $total_posts = count($all_posts);
    // Get current page URL
    $current_url = Morfy::factory()->getUrl();
    // Get current page data
    $current_page = Morfy::factory()->getPage($current_url);
    // Testing...
    // echo $current_page['date'];
    // Find next and previous link from current page
    $prev_page = $next_page = null;
    for($i = 0; $i < $total_posts; $i++) {
        if($current_page['date'] == $all_posts[$i]['date']) {
            $prev_page = isset($all_posts[$i - 1]['url']) && ! empty($all_posts[$i - 1]['url']) ? $all_posts[$i - 1]['url'] : null;
            $next_page = isset($all_posts[$i + 1]['url']) && ! empty($all_posts[$i + 1]['url']) ? $all_posts[$i + 1]['url'] : null;
        }
    }
    // Build the pagination
    $html  = '<ul class="' . $config['classes']['nav'] . '">';
    $html .= $prev_page !== null ? '<li class="' . $config['classes']['nav_prev'] . '"><a href="' . $prev_page . '">' . $config['labels']['nav_prev'] . '</a></li>' : '<li class="' . $config['classes']['nav_prev'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_prev'] . '</span></li>';
    $html .= $next_page !== null ? ' <li class="' . $config['classes']['nav_next'] . '"><a href="' . $next_page . '">' . $config['labels']['nav_next'] . '</a>' : ' <li class="' . $config['classes']['nav_next'] . ' ' . $config['classes']['nav_disabled'] . '"><span>' . $config['labels']['nav_next'] . '</span></li>';
    $html .= '</ul>';
    echo $html;
});

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

after

<?php
    return array(
        ...
        ...
        ...
        'plugins' => array(
            'markdown',
            'sitemap',
            'nextprev' // <= Activation
        ),
    );

template news.html

<?php include 'header.html' ?>
<?php include 'navbar.html' ?>
<div class="container">
    <?php Morfy::factory()->runAction('theme_content_before'); ?>
    <?php
    // Configuration data
    $config = Morfy::$config['nextprev_config'];
    // Get current URI segments
    $path = Morfy::factory()->getUriSegments();
    $path = implode('/', $path);
    // Number of posts to display per page request
    $per_page = isset($config['limit']) ? $config['limit'] : 5;
    // Get all posts
    $all_posts = Morfy::factory()->getPages(CONTENT_PATH . '/' . $path . '/', 'date', 'DESC', array('404', 'index'));
    // Calculate total pages
    $total_pages = ceil(count($all_posts) / $per_page);
    // Get current page offset
    $current_page = isset($_GET[$config['param']]) ? $_GET[$config['param']] : 1;
    // Split all posts into chunks
    $posts = is_array($all_posts) ? array_chunk($all_posts, $per_page) : array();
    // Posts loop
    if(isset($posts[$current_page - 1]) && ! empty($posts[$current_page - 1])) {
        foreach($posts[$current_page - 1] as $post) {
            echo '<div class="page">';
            echo $post['title'] ? '<h3><a href="' . $post['url'] . '">' . $post['title'] . '</a></h3>' : "";
            echo $post['date'] ? '<p><em><strong>Published on:</strong> ' . $post['date'] . '</em></p>' : "";
            if(strlen($post['description']) > 0) {
                echo '<p>' . $post['description'] . '</p>';
            } elseif(strlen($post['content_short']) > 0) {
                echo '<p>' . $post['content_short'] . '</p>';
            }
            echo '</div>';
        }
    } else {
        echo '<div class="page"><div class="alert alert-danger"><p>Not found.</p></div></div>';
    }
    // Build the pagination
    $html  = '<ul class="pager">';
    $html .= $current_page > 1 ? '<li class="previous"><a href="?page=' . ($current_page - 1) . '">← Previous</a></li>' : '<li class="previous disabled"><span>← Previous</span></li>';
    $html .= $current_page < $total_pages ? ' <li class="next"><a href="?page=' . ($current_page + 1) . '">Next →</a></li>' : ' <li class="next disabled"><span>Next →</span></li>';
    $html .= '</ul>';
    echo $html;
    ?>
    <?php Morfy::factory()->runAction('theme_content_after'); ?>
</div>
<?php include 'footer.html' ?>

code nextprev.php

<?php
/**
 * Next & Previous Navigation for Morfy CMS
 *
 * @package Morfy
 * @subpackage Plugins
 * @author Taufik Nurrohman <http://latitudu.com>
 * @copyright 2014 Romanenko Sergey / Awilum
 * @version 1.0.4
 *
 */
// Include `shell.css` in header
// Uncomment the hook function below if you are not using Bootstrap.
// Morfy::factory()->addAction('theme_header', function() {
//     echo '<link href="' . Morfy::$config['site_url'] . '/plugins/nextprev/lib/css/shell.css" rel="stylesheet">' . "\n";
// });
// For posts listing page
// Usage => Morfy::factory()->runAction('index_nextprev');
Morfy::factory()->addAction('index_nextprev', function() {
    // Configuration data
    $config = Morfy::$config['nextprev_config'];
    // Get current URI segments
    $path = Morfy::factory()->getUriSegments();
    $path = implode('/', $path);
    // Number of posts to display per page request
    $per_page = isset($config['limit']) ? $config['limit'] : 5;
    // Get all posts
    $all_posts = Morfy::factory()->getPages(CONTENT_PATH . '/' . $path . '/', 'date', 'DESC', array('404', 'index'));
    // Calculate total pages
    $total_pages = ceil(count($all_posts) / $per_page);
    // Get current page offset
    $current_page = isset($_GET[$config['param']]) ? $_GET[$config['param']] : 1;
    // Split all posts into chunks
    $posts = is_array($all_posts) ? array_chunk($all_posts, $per_page) : array();
    // Posts loop
    if(isset($posts[$current_page - 1]) && ! empty($posts[$current_page - 1])) {
        foreach($posts[$current_page - 1] as $post) {
            echo '<div class="page">';
            echo $post['title'] ? '<h3><a href="' . $post['url'] . '">' . $post['title'] . '</a></h3>' : "";
            echo $post['date'] ? '<p><em><strong>Published on:</strong> ' . $post['date'] . '</em></p>' : "";
            if(strlen($post['description']) > 0) {
                echo '<p>' . $post['description'] . '</p>';
            } elseif(strlen($post['content_short']) > 0) {
                echo '<p>' . $post['content_short'] . '</p>';
            }
            echo '</div>';
        }
    } else {
        echo '<div class="page"><div class="alert alert-danger"><p>Not found.</p></div></div>';
    }
    // Build the pagination
    $html  = '<ul class="pager">';
    $html .= $current_page > 1 ? '<li class="previous"><a href="?page=' . ($current_page - 1) . '">← Previous</a></li>' : '<li class="previous disabled"><span>← Previous</span></li>';
    $html .= $current_page < $total_pages ? ' <li class="next"><a href="?page=' . ($current_page + 1) . '">Next →</a></li>' : ' <li class="next disabled"><span>Next →</span></li>';
    $html .= '</ul>';
    echo $html;
});
// For single article
// Usage => Morfy::factory()->runAction('item_nextprev');
Morfy::factory()->addAction('item_nextprev', function() {
    // Configuration data
    $config = Morfy::$config['nextprev_config'];
    // Get current URI segments
    $path = Morfy::factory()->getUriSegments();
    array_pop($path);
    $path = implode('/', $path);
    // Get all posts
    $all_posts = Morfy::factory()->getPages(CONTENT_PATH . '/' . $path . '/', 'date', 'DESC', array('404', 'index'));
    // Count total posts
    $total_posts = count($all_posts);
    // Get current page URL
    $current_url = Morfy::factory()->getUrl();
    // Get current page data
    $current_page = Morfy::factory()->getPage($current_url);
    // Testing...
    // echo $current_page['date'];
    // Find next and previous link from current page
    $prev_page = $next_page = null;
    for($i = 0; $i < $total_posts; $i++) {
        if($current_page['date'] == $all_posts[$i]['date']) {
            $prev_page = isset($all_posts[$i - 1]['url']) && ! empty($all_posts[$i - 1]['url']) ? $all_posts[$i - 1]['url'] : null;
            $next_page = isset($all_posts[$i + 1]['url']) && ! empty($all_posts[$i + 1]['url']) ? $all_posts[$i + 1]['url'] : null;
        }
    }
    // Build the pagination
    $html  = '<ul class="pager">';
    $html .= $prev_page !== null ? '<li class="previous"><a href="' . $prev_page . '">← Previous</a></li>' : '<li class="previous disabled"><span>← Previous</span></li>';
    $html .= $next_page !== null ? ' <li class="next"><a href="' . $next_page . '">Next →</a>' : ' <li class="next disabled"><span>Next →</span></li>';
    $html .= '</ul>';
    echo $html;
});

what am I doing wrong and I spend white page;

Re: Blog Pagination (Next/Previous) for Morfy CMS

I think it is better to stop touching the config.php file. Switch back to the previous state. Just focus on your template content.

<?php include 'header.html' ?>
<?php include 'navbar.html' ?>
<div class="container">
    <?php Morfy::factory()->runAction('theme_content_before'); ?>
    <?php
    // Configuration data
    $config = array( // <= Configuration
        'param' => 'page', // <= Page parameter name in URL
        'limit' => 5, // <= Number of posts to display per page
        ...
    );
    ...
    ...
    ?>
    <?php Morfy::factory()->runAction('theme_content_after'); ?>
</div>
<?php include 'footer.html' ?>
XSS Testing <script>alert('HIYAA!!!');</script>

tovic's Website