Forum

Thread tagged as: Problem, Blog

Archive for Subcategories

Hello,

The achieve for a subcategory isn't showing it's posts.

In my example it should be getting blog/recipes/smoothies-juices whereas it's looking for just blog/smoothies-juices

Time    Δ  Debug Message
0.065   0   SELECT * FROM perch2_pages WHERE pagePath='/recipes/archive.php' LIMIT 1
0.0664  0.0015  SELECT * FROM perch2_categories WHERE catPath='blog/smoothies-juices/' LIMIT 1
0.0688  0.0024  SELECT 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 'blog/smoothies-juices/%' OR idx.indexKey='_category' AND idx.indexValue='blog/smoothies-juices/')
0.0702  0.0014  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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2015-03-18 16:02:00' ) GROUP BY itemID ORDER BY sortval DESC LIMIT 0, 10
0.0718  0.0016  SELECT FOUND_ROWS() AS `count`
0.0728  0.0011  SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
0.0755  0.0027  Using template: /templates/blog/post_in_list_all-10.html

Can I modify it to look at catPath?

Sarah Evans

Sarah Evans 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you passing the path on the URL?

Not sure I follow. I've not altered the default archive.php file code (below).

This seems to be looking for blog/smoothies-juices when actually it should be looking for blog/recipes/smoothies-juices as it is a subcategory.

                    perch_blog_custom(array(
                            'category'   => perch_get('cat'),
                            'template'   => $template,
                            'count'      => $posts_per_page,
                            'sort'       => $sort_by,
                            'sort-order' => $sort_order,

                            ));

                    $posts_displayed = true;
                }


Drew McLellan

Drew McLellan 2638 points
Perch Support

Does the URL look like

?cat=recipes/smoothies-juices

?

No just

?cat=smoothies-juices
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok. If you use catPath instead of catSlug when creating the link, you should get the full path.

Otherwise Perch can't know where smoothies-juices appears in the category tree, or if it appears multiple times which one you mean.

Ah great.

For some reason I thought it would be more complex than that. Thank you!