Forum

Thread tagged as: Problem, Blog

Blog Posts sort order not working

Hi, I have an array set to display older blog posts in a random fashion, however this is being ignored by Perch which is choosing to sort them by Ascending order. Any idea why this might be happening?

Code

        <div class="col-2 prj-col-2 w-col w-col-9">
        <h1 class="h1-centered">Read Older Blog Posts</h1>

        <?php
      perch_blog_custom(array(
        'filter' => 'postDateTime', 
        'match' => 'eqbetween',
        'sort-order' => 'RAND',
        'template' => 'base_list.html',
        'count' => 3

    ));
    ?>
      </div>

Base List template


<div class="blog-col w-col w-col-3 w-col-medium-6"> <div class="blog-list-wrapper"> <div class="snippet-box"> <h3><perch:blog id="postTitle" /></h3> <h5><perch:blog id="postDateTime" format="d M Y" /></h5> </div> <div class="blog-list-image"> <a class="w-inline-block" href="<perch:blog id="postURL" />"><img src="<perch:blog id="image" type="image" width="200" height="100" crop="true" />" alt="<perch:blog id="postTitle" />"></a> </div> <div class="snippet-box-under"> </div><a class="button w-button" href="<perch:blog id="postURL" />">Read More</a> </div> </div>

Debug Message

Debug Message - Perch 3.1.1
[1] SELECT u.*, r.* FROM perch3_users u, perch3_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=2 AND u.userHash='c9d88bb27792a4f78347fb38970685f6' LIMIT 1
UPDATE perch3_users SET userHash='cb463ee9742be146c4ab9dfcd4985516' WHERE userID='2'
[32] SELECT settingID, settingValue, userID FROM perch3_settings WHERE userID=2 OR userID=0 ORDER BY userID ASC
[7] SELECT itemValue FROM perch3_menu_items WHERE itemType='app'
[0] SELECT COUNT(*) FROM perch3_blog_comments WHERE commentStatus='PENDING'
[1] SELECT * FROM perch3_blog_authors WHERE authorEmail='james@mckevittarchitects.ie' LIMIT 1
[1] SELECT * FROM perch3_blog_posts WHERE postID=25
[1] SELECT * FROM perch3_blog_sections ORDER BY sectionTitle ASC
[1] SELECT * FROM perch3_blogs ORDER BY blogTitle ASC
[1] SELECT * FROM perch3_blogs WHERE blogID=1 LIMIT 1
[1] SELECT * FROM perch3_blog_sections WHERE blogID='1' ORDER BY sectionTitle ASC
Using template: /templates/blog/post.html
[1] SELECT * FROM perch3_resources WHERE resourceID='1573' LIMIT 1
[1] SELECT * FROM perch3_resources WHERE resourceAWOL=0 AND resourceParentID='1573' AND resourceKey='thumb'
[1] SELECT * FROM perch3_resources WHERE resourceAWOL=0 AND resourceParentID='1573' AND resourceTargetWidth=1000 AND resourceTargetHeight=800 AND resourceCrop=0 AND resourceDensity=1
Logging resources for perch_blog
DELETE FROM perch3_resource_log WHERE appID='perch_blog' AND itemFK='postID' AND itemRowID=25
INSERT IGNORE INTO perch3_resource_log(`appID`, `itemFK`, `itemRowID`, `resourceID`) VALUES('perch_blog','postID',25,1573),('perch_blog','postID',25,1574),('perch_blog','postID',25,1576)
UPDATE perch3_blog_posts SET postStatus='Published', postTemplate='post.html', postDescRaw='<p>Kate has joined us for a second summer. A second year Architecture student studying in UCD, Kate will assist with the preparation of planning applications, measured surveys and general administration.</p>', postDescHTML='<p>Kate has joined us for a second summer. A second year Architecture student studying in UCD, Kate will assist with the preparation of planning applications, measured surveys and general administration.</p>', postTitle='Kate Shevlin joins the office', postDateTime='2018-05-22 13:22:00', postDynamicFields='{\"image\":{\"assetID\":\"1573\",\"title\":\"RHP 2239 small\",\"_default\":\"\\/perch\\/resources\\/rhp2239-small.jpg\",\"bucket\":\"default\",\"path\":\"rhp2239-small.jpg\",\"size\":668290,\"w\":2000,\"h\":1450,\"mime\":\"image\\/jpeg\",\"sizes\":{\"thumb\":{\"w\":\"150\",\"h\":\"108\",\"target_w\":150,\"target_h\":150,\"density\":2,\"path\":\"rhp2239-small-thumb@2x.jpg\",\"size\":22335,\"mime\":\"image\\/jpeg\",\"assetID\":\"1574\"},\"w1000h800c0\":{\"w\":\"1000\",\"h\":\"725\",\"target_w\":\"1000\",\"target_h\":\"800\",\"crop\":false,\"density\":\"1\",\"path\":\"rhp2239-small-w1000h800.jpg\",\"size\":182023,\"mime\":\"\",\"assetID\":\"1576\"}}},\"categories\":null}' WHERE postID='25'
No ids to log.
UPDATE perch3_blog_posts SET postStatus='Published', postTemplate='post.html', postDescRaw='<p>Kate has joined us for a second summer. A second year Architecture student studying in UCD, Kate will assist with the preparation of planning applications, measured surveys and general administration.</p>', postDescHTML='<p>Kate has joined us for a second summer. A second year Architecture student studying in UCD, Kate will assist with the preparation of planning applications, measured surveys and general administration.</p>', postTitle='Kate Shevlin joins the office', postDateTime='2018-05-22 13:22:00', postDynamicFields='{\"image\":{\"assetID\":\"1573\",\"title\":\"RHP 2239 small\",\"_default\":\"\\/perch\\/resources\\/rhp2239-small.jpg\",\"bucket\":\"default\",\"path\":\"rhp2239-small.jpg\",\"size\":668290,\"w\":2000,\"h\":1450,\"mime\":\"image\\/jpeg\",\"sizes\":{\"thumb\":{\"w\":\"150\",\"h\":\"108\",\"target_w\":150,\"target_h\":150,\"density\":2,\"path\":\"rhp2239-small-thumb@2x.jpg\",\"size\":22335,\"mime\":\"image\\/jpeg\",\"assetID\":\"1574\"},\"w1000h800c0\":{\"w\":\"1000\",\"h\":\"725\",\"target_w\":\"1000\",\"target_h\":\"800\",\"crop\":false,\"density\":\"1\",\"path\":\"rhp2239-small-w1000h800.jpg\",\"size\":182023,\"mime\":\"\",\"assetID\":\"1576\"}}},\"categories\":null}', postSlug='2018-05-22-kate-shevlin-joins-the-office' WHERE postID='25'
No ids to log.
DELETE FROM perch3_blog_index WHERE itemKey='postID' AND itemID='25'
[5] SELECT * FROM perch3_blog_authors ORDER BY authorFamilyName, authorGivenName ASC
INSERT INTO perch3_blog_index (itemKey, itemID, indexKey, indexValue) VALUES ('postID',25,'image','/perch/resources/rhp2239-small.jpg'),('postID',25,'postID','25'),('postID',25,'blogID','1'),('postID',25,'postTitle','Kate Shevlin joins the office'),('postID',25,'postSlug','2018-05-22-kate-shevlin-joins-the-office'),('postID',25,'postDateTime','2018-05-22 13:22:00'),('postID',25,'postDescRaw','<p>Kate has joined us for a second summer. A second year Architecture student studying in UCD, Kate will assist with the preparation of planning applications, measured surveys and general administration.</p>'),('postID',25,'postDescHTML','<p>Kate has joined us for a second summer. A second year Architecture student studying in UCD, Kate will assist with the preparation of planning applications, measured surveys and general administration.</p>'),('postID',25,'postTags',''),('postID',25,'postStatus','Published'),('postID',25,'authorID','0'),('postID',25,'sectionID','1'),('postID',25,'postCommentCount','0'),('postID',25,'postImportID',''),('postID',25,'postLegacyURL',''),('postID',25,'postAllowComments','1'),('postID',25,'postTemplate','post.html'),('postID',25,'postMetaTemplate','post_meta.html'),('postID',25,'itemID',''),('postID',25,'itemRowID',''),('postID',25,'postURL','/blog/post.php?s=2018-05-22-kate-shevlin-joins-the-office'),('postID',25,'_id',25)
[1] OPTIMIZE TABLE perch3_blog_index
[nil] SELECT COUNT(*) AS qty, c.catID FROM perch3_blog_index i, perch3_categories c, perch3_blog_posts p WHERE i.indexValue=c.catPath AND i.indexKey='_category' AND i.itemKey='postID' AND i.itemID=p.postID AND p.postStatus='Published' AND p.postDateTime<='2018-06-14 07:31:00' GROUP BY i.indexValue, c.catID
DELETE FROM perch3_category_counts WHERE countType='blog.post'
[2] SELECT authorID, COUNT(*) AS qty FROM perch3_blog_posts WHERE postStatus='Published' AND postDateTime<='2018-06-14 07:31:00' GROUP BY authorID
UPDATE perch3_blog_authors SET authorPostCount=0
UPDATE perch3_blog_authors SET authorPostCount='14' WHERE authorID=0 LIMIT 1
UPDATE perch3_blog_authors SET authorPostCount='1' WHERE authorID=5 LIMIT 1
[1] SELECT c.sectionID, COUNT(p.postID) AS qty FROM perch3_blog_sections c, perch3_blog_posts p WHERE c.sectionID=p.sectionID AND p.postStatus='Published' AND p.postDateTime<='2018-06-14 07:31:00' GROUP BY c.sectionID ORDER BY c.sectionTitle ASC
UPDATE perch3_blog_sections SET sectionPostCount=0
UPDATE perch3_blog_sections SET sectionPostCount='15' WHERE sectionID='1' LIMIT 1
Edit mode: edit
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1
[2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC
[1] SELECT itemTitle FROM perch3_menu_items WHERE itemType='app' AND itemValue='perch_blog' LIMIT 1
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10
[2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC
File: /addons/apps/perch_blog/modes/edit.post.php
[1] SELECT * FROM perch3_resources WHERE resourceID='1573' LIMIT 1
[nil] SELECT * FROM perch3_categories c, perch3_category_sets s WHERE c.setID=s.setID AND s.setSlug='blog' ORDER BY catTreePosition ASC

Diagnostics

Health check
 Perch is up to date
 PHP 5.6.36 is up to date
 MySQL 5.5.5-10.1.33-MariaDB is up to date
 Image processing available
Summary information
Perch: 3.1.1, PHP: 5.6.36, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.1.1), assets (3.1.1), categories (3.1.1), perch_blog (5.5.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/mckevit1/public_html/perch
PERCH_CORE: /home/mckevit1/public_html/perch/core
PERCH_RESFILEPATH: /home/mckevit1/public_html/perch/resources
Image manipulation: GD
PHP limits: Max upload 1000M, Max POST 1000M, Memory: 256M, Total max file upload: 256M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/mckevit1/public_html
HTTP_HOST: www.mckevittarchitects.ie
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Cormac Kerrigan

Cormac Kerrigan 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to set sort in order to use sort-order.

Grazie!