Forum

Thread tagged as: Problem, Blog

perch _custom 'start' trouble

Hello again, I recently had the same trouble with perch_content_custom but now am having it with perch_blog_custom

I have a post listing page. I want the first post to use a different template than the rest...

<?php

     PerchSystem::set_var('page', 'home');
     perch_blog_custom(array(
          'template' => 'feature_post.html',
          'sort' => 'postDateTime',
          'sort-order' => 'DESC',
          'count' => 1,
     ));

     perch_blog_custom(array(
          'count' => 6,
          'start' => 2,
          'template' => 'post_in_list.html',
          'sort' => 'postDateTime',
          'sort-order' => 'DESC',
         'paging' => false,
     ));
?>

I believe the answer that worked for me last time was that 'start' always needs 'count'. However, the second perch_blog call here still returns the most recent post.

Anything jumping out?

Nicholas Nelson

Nicholas Nelson 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me the output from debug?

Hey, I'm sorry I just got back to this.

This is what gets output to the page


Time Δ Message 0.0602 0 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' WHERE 1=1 AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID ) as tbl WHERE (postStatus='Published' AND postDateTime<='2014-10-31 22:30:00' ) GROUP BY itemID ORDER BY sortval DESC LIMIT 0, 1 0.0694 0.0092 SELECT FOUND_ROWS() AS `count` 0.0705 0.0011 SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0 0.0725 0.002 Using template: /templates/blog/feature_post.html 0.0733 0.0008 SELECT * FROM perch2_blog_sections ORDER BY sectionTitle ASC 0.0748 0.0015 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' WHERE 1=1 AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID ) as tbl WHERE (postStatus='Published' AND postDateTime<='2014-10-31 22:30:00' ) GROUP BY itemID ORDER BY sortval DESC LIMIT 0, 6 0.0825 0.0078 SELECT FOUND_ROWS() AS `count` 0.0827 0.0002 Using template: /templates/blog/post_in_list.html
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that doesn't look right. I'll take a look at it.

Hey Drew, just checking in... I noticed there was a new Perch Blog version 4.5.4. I drop that and perch 2.7.3 core in and am still having the same issue. Should I be expecting no change in this version?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I was hoping there might be, but if not I'll take another look.

Yeah, my output is still the same, sorry!

Hello again, I just revisited this while updating to perch 2.7.4.

Still the same result.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, it wasn't included in 2.7.4.