Forum

Thread tagged as: Problem, Blog

blog app pagination in archive

Hello, i using perch blog app (v 5.0) and have following problem:

this is my archive.php


// defaults for all modes $posts_per_page = 1; $template = 'post_in_list.html'; $sort_order = 'DESC'; $sort_by = 'postDateTime'; // Have we displayed any posts yet? $posts_displayed = false; /* perch_get() is used to get options from the URL. e.g. for the URL /blog/archive.php?cat=news perch_get('cat') would return 'news' because cat=news. The code below looks for different options in the URL, and then displays different types of listings based on it. */ /* --------------------------- POSTS BY CATEGORY --------------------------- */ if (perch_get('cat')) { echo '<h2>'.perch_blog_category(perch_get('cat'), true).'</h2>'; perch_blog_custom(array( 'category' => perch_get('cat'), 'template' => $template, 'count' => $posts_per_page, 'sort' => $sort_by, 'sort-order' => $sort_order, )); $posts_displayed = true; } /* --------------------------- POSTS BY TAG --------------------------- */ if (perch_get('tag')) { echo '<h2>'.perch_blog_tag(perch_get('tag'), true).'</h2>'; perch_blog_custom(array( 'tag' => perch_get('tag'), 'template' => $template, 'count' => $posts_per_page, 'sort' => $sort_by, 'sort-order' => $sort_order, )); $posts_displayed = true; } /* --------------------------- POSTS BY DATE RANGE --------------------------- */ if (perch_get('year')) { $year = intval(perch_get('year')); $date_from = $year.'-01-01 00:00:00'; $date_to = $year.'-12-31 23:59:59'; $title_date_format = '%Y'; // Month and Year? if (perch_get('month')) { $month = intval(perch_get('month')); $date_from = $year.'-'.str_pad($month, 2, '0', STR_PAD_LEFT).'-01 00:00:00'; $date_to = $year.'-'.str_pad($month, 2, '0', STR_PAD_LEFT).'-31 23:59:59'; $title_date_format = '%B, %Y'; } echo '<h1>Archive of: '.strftime($title_date_format, strtotime($date_from)).'</h1>'; perch_blog_custom(array( 'filter' => 'postDateTime', 'match' => 'eqbetween', 'value' => $date_from.','.$date_to, 'template' => $template, 'count' => $posts_per_page, 'sort' => $sort_by, 'sort-order' => $sort_order, )); $posts_displayed = true; } /* --------------------------- POSTS BY AUTHOR --------------------------- */ if (perch_get('author')) { perch_blog_author(perch_get('author'), array( 'template' => 'author_name.html', )); perch_blog_custom(array( 'author' => perch_get('author'), 'template' => $template, 'count' => $posts_per_page, 'sort' => $sort_by, 'sort-order' => $sort_order, )); $posts_displayed = true; } /* --------------------------- DEFAULT: ALL POSTS --------------------------- */ if ($posts_displayed == false) { // No other options have been used; no posts have been displayed yet. // So display all posts. echo '<h1>Archive</h1>'; perch_blog_custom(array( 'template' => $template, 'count' => $posts_per_page, 'sort' => $sort_by, 'sort-order' => $sort_order, )); }
post in list template:

<div class="row single-article">
    <div class="col-md-7 col-sm-6">
        <a href="<perch:blog id="postURL" />">
            <img src="<perch:blog id="ListingImage" type="image" />" alt="<perch:blog id="postTitle" />">
        </a>
    </div>
    <div class="col-md-5 col-sm-5">
        <p class="title"><a href="<perch:blog id="postURL" />"><perch:blog id="postTitle" /></a></p>
        <small><perch:blog id="postDateTime" type="date" time="true" format="d.m.Y" /></small><small><perch:categories id="categories" set="blog" label="Categories" display-as="checkboxes"><a href="/blog/kategoria/<perch:category id="catSlug" type="slug" />"><perch:category id="catTitle" type="text" /> </a></perch:categories></small>
        <perch:if exists="excerpt"><p class="description"><perch:blog id="excerpt" /> ...</p></perch:if>
    </div>
</div>
<perch:after>
    <perch:if exists="paging">
        <div class="row">
            <div class="col-md-12">
                <perch:blog id="page_links" encode="false" />
                <perch:if exists="not_first_page">
                    <a href="/blog<perch:blog id="prev_url" rewrite="{page:/%s}" encode="false" />"class="customButtonBlue" style="float:left;">novšie</a>
                </perch:if>
                <perch:if exists="not_last_page">
                    <a href="/blog<perch:blog id="next_url" rewrite="{page:/%s}" encode="false" />"class="customButtonBlue" style="float:right;">staršie</a>
                </perch:if>

            </div>
        </div>
    </perch:if>
</perch:after>

URL is wrong i know but when i try url: /blog/kategoria/socialne-siete/2 or /blog/kategoria/socialne-siete?page=2 there is no post to show

DEBUG MESSAGE

Debug Message
Fetching from cache: perch_blog_categoriesb87a59a6c498d895119bd34053c48f8a
Cache file not found: perch_blog_categoriesb87a59a6c498d895119bd34053c48f8a
[1] SELECT setID FROM perch2_category_sets WHERE setSlug='blog' LIMIT 1
[nil] SELECT main.* , COALESCE(cc.countValue,0) AS `count.blog.post` FROM perch2_categories main LEFT OUTER JOIN perch2_category_counts cc ON cc.catID=main.catID WHERE 1=1 AND (catSlug='socialne-siete/2') AND setID=1 AND (cc.countType='blog.post' OR cc.countType IS NULL) AND cc.countValue > 0 ORDER BY catTreePosition ASC
[24] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
Using template: /templates/blog/seo.html
Fetching from cache: perch_blog_category1663875887e29b1332798616ca77782e
Cache file not found: perch_blog_category1663875887e29b1332798616ca77782e
[1] SELECT * FROM perch2_categories WHERE catPath='socialne-siete/2' LIMIT 1
[0] SELECT DISTINCT idx.itemID FROM perch2_blog_index idx JOIN perch2_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' AND (idx.indexKey='_category' AND idx.indexValue LIKE 'socialne-siete/2%' OR idx.indexKey='_category' AND idx.indexValue='socialne-siete/2')
[nil] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_blog_index idx JOIN perch2_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN perch2_blog_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='postDateTime' AND idx.itemID IN (NULL) WHERE 1=1 AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID, idx2.indexValue, postID ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-07-19 12:16:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 1
[1] SELECT FOUND_ROWS() AS `count`
Using template: /templates/blog/post_in_list.html

My htaccess:

RewriteRule ^blog/clanok/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]
RewriteRule ^blog/autor/([a-zA-Z0-9-/]+)$ /blog/archive.php?author=$1 [L]
RewriteRule ^blog/kategoria/([a-zA-Z0-9-/]+)$ /blog/archive.php?cat=$1 [L]
RewriteRule ^blog/tag/([a-zA-Z0-9-/]+)$ /blog/archive.php?tag=$1 [L]
RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/?page=$1 [L]
Pavol Krchnavy

Pavol Krchnavy 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

This rule doesn't match your URL format for pagination:

RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/?page=$1 [L]