Re: Blog Pagination (Next/Previous) for Morfy CMS
@tovic
1) Tags Page
2) Page Views Counter
3) Next/Previous Navigation
I installed but spend error
( ! ) Parse error: syntax error, unexpected ''tags_config'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in C:\wamp\www\demo\config.php on line 22 Call Stack # Time Memory Function Location 1 0.0010 250960 {main}( ) ..\index.php:0 2 0.0040 403608 Morfy->run( ) ..\index.php:47 3 0.0040 403648 Morfy->loadConfig( ) ..\Morfy.php:138
config.php
<?php return array( 'site_url' => 'http://localhost/demo', 'site_charset' => 'UTF-8', 'site_timezone' => 'Kwajalein', 'site_theme' => 'default', 'site_title' => 'demo', 'site_description' => 'demo', 'site_keywords' => 'demo', 'email' => 'demo@gmail.com', 'plugins' => array( 'markdown', 'sitemap', 'pageview', 'tags', 'nextprev' ), 'pageview_config' => array( // Change to `false` if you want to remove the leading zero in counter 'leading_zero' => '000000' ) 'tags_config' => array( // <= Configuration 'param' => 'tagged', // <= Page parameter name in URL for the tags filter 'param_page' => 'page', // <= Page parameter name in URL for the page filter 'limit' => 5, // <= Number of posts to display per page request 'separator' => ', ', // <= Separator for each tag link 'classes' => array( // <= List of item's HTML classes 'page_item' => 'page', 'nav' => 'pager', 'nav_prev' => 'previous', 'nav_next' => 'next', 'nav_disabled' => 'disabled', 'tag' => 'tag', 'current' => 'current' ), 'labels' => array( // <= List of item's readable text or labels 'page_header' => '<div class="alert alert-info"><p>Showing posts tagged in <strong>{tag}</strong>.</p></div>', 'nav_prev' => '← Previous', 'nav_next' => 'Next →', 'not_found' => '<div class="alert alert-danger"><p>No more posts found tagged in <strong>{tag}</strong>.</p></div>' ) ) 'nextprev_config' => array( // <= Configuration 'param' => 'page', // <= Page parameter name in URL 'limit' => 5, // <= Number of posts to display per page request '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>' ) ) );
tempate news.html
<?php include 'header.html' ?> <?php include 'navbar.html' ?> <?php Morfy::factory()->runAction('theme_content_before'); ?> <div class="container"> <div class="row"> <div class="col-md-12"> <?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(); $tag_filter = Morfy::$config['tags_config']['param']; if(isset($tag_filter) && isset($_GET[$tag_filter])) { // Tags page Morfy::factory()->runAction('tags'); } else { // Normal posts loop Morfy::factory()->runAction('index_nextprev'); } // Posts loop if(isset($posts[$current_page - 1]) && ! empty($posts[$current_page - 1])) { foreach($posts[$current_page - 1] as $post) { // use default image if not write Thumbnail $thumbnail = ($post['thumbnail']) ? $post['thumbnail'] : $config['Site_url'].'public/images/default.jpg'; echo '<div class="tumb-grid"><img src="'.$thumbnail.'" alt="'.$post['title'].'" data-holder-rendered="true" style="height: 200px; width: 100%; display: block;"><h3><a href="'.$config['site_url'].'/blog/'.$post['slug'].'">'.$post['title'].'</a></h3> </div>'; } } else { echo '<div class="' . $config['classes']['page_item'] . '">' . $config['labels']['not_found'] . '</div>'; } ?> </div> </div> <div class="row"> <div class="col-md-12"> <?php // 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; ?> </div> </div> </div> <?php Morfy::factory()->runAction('theme_content_after'); ?> <?php include 'footer.html' ?>
news_post.html
<?php include 'header.html' ?> <?php include 'navbar.html' ?> <div class="container"> <?php Morfy::factory()->runAction('theme_content_before'); ?> <h3><?php echo $page['title']; ?></h3> <?php $thumbnail = ($page['thumbnail']) ? $page['thumbnail'] : $config['Site_url'].'public/images/default.jpg'; ?> <div class="tumb"> <img src="<?php echo $thumbnail;?>" alt="<?php echo $page['title'];?>"> </div> <p>Posted on <?php echo $page['date']; ?></p> <div><?php echo $page['content']; ?></div> <span class="page-views"> <strong class="page-views-label">Total Page Views:</strong> <span class="page-views-counter"> <?php Morfy::factory()->runAction('pageview'); ?> </span> </span> <div class="post-tags"> <?php Morfy::factory()->runAction('tags_links'); ?> </div> <?php Morfy::factory()->runAction('item_nextprev'); ?> <?php Morfy::factory()->runAction('theme_content_after'); ?> <hr> </div> <?php include 'footer.html' ?>
I did not touch any file!
and I get this error