Forum

Thread tagged as: Question

Category Filtering in Template

Hello,

I was wondering if it's possible to filter a categories field by level within a template?

Here's what I'm using in my template:

<perch:categories id="dept" label="Department(s)" set="departments" />

For my Departments set, I have something like the following structure:

  • Academics: Mathematics, Science, History
  • Educational Support: Counselors, Health Services, Library
  • Athletics: Soccer, Basketball, Baseball

When I go to edit a region item, my department's field lists all categories and sub-categories - which is nice. However, I wonder if there's a way I can list the 1st level of categories without their subcategories, for example:

  • Academics
  • Educational Support
  • Athletics

I know I could just create another category set for each 1st level category. But I like the idea of keeping things organized under my Departments category set.

Any ideas?

Joshua Rodriguez

Joshua Rodriguez 2 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You should be able to filter for catDepth in your template.

<perch:if id="catDepth" value="1">
...
</perch:if>

Thanks Drew, exactly what I was looking for.

I have a question regarding Runway and routes for this, too.

In my blog I have the following route setup and it works well for my blog archives page:

blog/category/[slug:cat]

How would I setup a route for subcategories of my blog categories?

For example, I have a set named Blog. The above route works fine for a category of "Athletics" in my set. However, if I add a sub-category to Athletics of "Baseball", I get no results. Baseball becomes another item listed under my categories navigation for my page, but when I select it, the archive page displays with no results and the URL I see is "mysite.com/blog/category/baseball".

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to use what we call the category path which is a path made up of the set slug and then the category slugs:

departments/athletics/baseball

Use that in your URL, and in your route pattern, you'll need to add entries to match the URL as it gets progressively longer. (We have a more elegant solution for that coming in Perch 2.9)

Thanks Drew. Very much looking forward to the 2.9 updates.

Ok, so I did this in my category_link.html template:

<a href="/blog/category<perch:category id="catPath" replace="blog| " />">

I used the replace attribute tag because my url was displaying as mysite.com/blog/category/blog/athletics/baseball. So now I'm getting the URL I want: mysite.com/blog/category/athletics/baseball.

I also added this route pattern to my Archive page:

blog/category/[slug:cat]/[slug:subcat]

Now all my categories are displaying results. The thing is that when I select my "baseball" category link, I get all my "athletics" posts, including my "baseball" posts. So something isn't right. Same if I select my "basketball" category - also a subcategory of Athletics. The post results include everything categorized under Athletics, so all posted categorized as:

  • athletics
  • athletics/baseball
  • athletics/basketball

...and so on. What am I missing or overlooking? Did I setup my new route correctly?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is you're category set called "blog"? I thought from the example above it was "departments".

I think you'll need to show me what you're doing, otherwise I can only guess.

Drew,

Sorry for the confusion...I probably should have started another thread or should have clarified after seeing your last reply was referring to my departments category set.

I have a Departments Directory page in my website and wanted to organize the directory using categories, but I wanted to make sure that I could reuse this organization on other pages in my website and restrict on those pages, which categories in my Departments Set editors could select from. This was possible after you suggested I use catDepth filtering.

My question about setting up a route in Runway is in reference to categories of my Blog Set for the blog app. This set has categories and another level of subcategories.

The first level of categories works fine with my route setup as:

blog/category/[slug:cat]

My problem is displaying results from the subcategories level. This was my original template code for my blog template of category_link.html:

<li><a href="/blog/category/<perch:category id="catSlug" />"><perch:category id="catTitle" /> (<perch:category id="count.blog.post" when-empty="0" />)</a></li>

For my blog categories (category: athletics) this would display as mysite.com/blog/category/athletics which worked fine.

However for my blog subcategories (category: athletics/baseball) this would display as mysite.com/blog/category/baseball which would not work.

So I modified my template to the following:

<li><a href="/blog/category<perch:category id="catPath" replace="blog| " />"><perch:category id="catTitle" /> (<perch:category id="count.blog.post" when-empty="0" />)</a></li>

I used the replace attribute to change the URL from mysite.com/blog/category/blog/athletics to mysite.com/blog/category/athletics.

Then I added a new route - can't say I knew 100% what I was doing here, but this seemed to work:

blog/category/[slug:cat]/[slug:subcat]

Now for my blog categories (category: athletics) this displays as mysite.com/blog/category/athletics and works fine, and for my blog subcategories (category: athletics/baseball) this displays as mysite.com/blog/category/athletics/baseball which does display posts, but not just "baseball" posts. This displays baseball posts and all posts of the parent category "athletics" and all subcategories of athletics.

I have the following categories setup in my Blog set:

  • Athletics
  • Athletics/Baseball
  • Athletics/Basketball

Clicking on the link to any of these three displays the same posts. I could understand how clicking on Athletics would display posts in its category and subcategories, but clicking on Athletics/Baseball should only display posts for baseball, not all athletics and all subcategories of athletics like athletics/basketball ...right??

Hopefully I explained it well?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me the debug output from this page?

mysite.com/blog/category/athletics/baseball

I just finished applying a change client requested for URL to display "news" instead of "blog". So I changed the folder name to news, updated all links, templates, routes, and post page path under Settings. Tested and all is functioning the same.

Here is the debug output from: mysite.com/news/category/athletics/baseball.

Time    Δ   Debug Message
0.0447  0   [229] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM seg_pages p LEFT JOIN seg_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
0.0515  0.0069  Matched route: news/category/[slug:cat]/[slug:subcat]
0.0518  0.0002  Using master page: \templates\pages\news\archive.php
0.0518  0   Page arguments:
Array
(
    [0] => /news/category/athletics/baseball
    [cat] => athletics
    [1] => athletics
    [subcat] => baseball
    [2] => baseball
)
0.0569  0.0051  [1] SELECT * FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1
0.0592  0.0024  Using template: \templates\pages\attributes\default.html
0.0603  0.0011  Using sub-template: \templates\pages/attributes/seo.html
0.0616  0.0013  [1] SELECT groupID FROM seg_navigation WHERE groupSlug='informational-navigation' LIMIT 1
0.0621  0.0005  [4] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=1 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.063   0.0009  [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=1 AND p.pagePath='/news/archive' LIMIT 1
0.064   0.001   [4] Using template: \templates\navigation\inform_nav.html
0.0665  0.0025  Using template: \templates\search\search-form.html
0.0695  0.003   [211] SELECT * FROM seg_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC
0.0769  0.0074  [1] SELECT pageTreePosition FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1
0.0774  0.0006  [2] SELECT pageID FROM seg_pages WHERE pageTreePosition IN ('000-009-003', '000-009', '000') ORDER BY pageTreePosition DESC
0.0815  0.0041  Using template: \templates\navigation\main_nav.html
0.082   0.0005  [4] Using template: \templates\navigation\main_navsub.html
0.0839  0.0019  [4] Using template: \templates\navigation\main_navsub.html
0.139   0.0551  [4] Using template: \templates\navigation\main_navsub.html
0.1439  0.0049  [6] Using template: \templates\navigation\main_navsub.html
0.1515  0.0076  [211] SELECT * FROM seg_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC
0.1602  0.0088  [1] SELECT pageTreePosition FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1
0.1612  0.001   [2] SELECT pageID FROM seg_pages WHERE pageTreePosition IN ('000-009-003', '000-009', '000') ORDER BY pageTreePosition DESC
0.1657  0.0044  Using template: \templates\navigation\main_nav2.html
0.1661  0.0004  [4] Using template: \templates\navigation\main_navsub.html
0.168   0.002   [4] Using template: \templates\navigation\main_navsub.html
0.226   0.058   [4] Using template: \templates\navigation\main_navsub.html
0.2312  0.0051  [6] Using template: \templates\navigation\main_navsub.html
0.2416  0.0104  [1] SELECT * FROM seg_categories WHERE catPath='blog/athletics/' LIMIT 1
0.2546  0.013   [4] SELECT DISTINCT idx.itemID FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' AND ((idx.indexKey='_category' AND idx.indexValue LIKE 'blog/athletics/%' OR idx.indexKey='_category' AND idx.indexValue='blog/athletics/'))
0.2567  0.0022  [4] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_blog_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='postDateTime' AND idx.itemID IN ('10', '33', '37', '34') WHERE 1=1 AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-03 13:28:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 10
0.2646  0.0079  [1] SELECT FOUND_ROWS() AS `count`
0.2672  0.0026  [31] SELECT DISTINCT settingID, settingValue FROM seg_settings WHERE userID=0
0.2749  0.0077  [4] Using template: \templates\blog\post_in_list.html
0.2769  0.002   [1] SELECT * FROM seg_blog_sections ORDER BY sectionTitle ASC
0.2788  0.0019  [1] SELECT * FROM seg_blogs ORDER BY blogTitle ASC
0.2798  0.001   [4] SELECT * FROM seg_categories ORDER BY catTreePosition ASC
0.2957  0.0159  [1] SELECT setID FROM seg_category_sets WHERE setSlug='blog' LIMIT 1
0.2964  0.0007  [9] SELECT main.* , COALESCE(cc.countValue,0) AS `count.blog.post` FROM seg_categories main LEFT OUTER JOIN seg_category_counts cc ON cc.catID=main.catID WHERE 1=1 AND setID=11 AND (cc.countType='blog.post' OR cc.countType IS NULL) AND cc.countValue > 0 ORDER BY catTreePosition ASC
0.3014  0.005   [9] Using template: \templates\blog\category_link.html
0.3058  0.0044  [1] SELECT * FROM seg_blogs WHERE blogSlug='blog' LIMIT 1
0.3063  0.0005  [nil] SELECT t.tagTitle, t.tagSlug, COUNT(p2t.postID) AS qty FROM seg_blog_tags t, seg_blog_posts_to_tags p2t, seg_blog_posts p WHERE p2t.tagID=t.tagID AND p2t.postID=p.postID AND p.postStatus='Published' AND p.postDateTime<='2016-10-03 13:28:00' AND p.blogID=1 GROUP BY t.tagID ORDER BY t.tagTitle ASC
0.3071  0.0008  [] Using template: \templates\blog\tag_link.html
0.3073  0.0002  [1] SELECT year(postDateTime) as year, COUNT(*) AS year_qty FROM seg_blog_posts WHERE postStatus='Published' AND postDateTime<='2016-10-03 13:28:00' GROUP BY year ORDER BY year DESC
0.3088  0.0015  Using template: \templates\blog\months_month_link.html
0.309   0.0002  [6] SELECT DISTINCT year(postDateTime) AS year, month(postDateTime) AS month, CONCAT(year(postDateTime),"-",month(postDateTime),"-01") AS postDateTime, COUNT(*) AS month_qty FROM seg_blog_posts p WHERE year(postDateTime) = '2016' AND p.postStatus='Published' AND p.postDateTime<='2016-10-03 13:28:00' GROUP BY year, month ORDER BY month DESC
0.3142  0.0052  [1] Using template: \templates\blog\months_year_link.html
0.3158  0.0017  [1] SELECT groupID FROM seg_navigation WHERE groupSlug='explore-goode' LIMIT 1
0.3164  0.0006  [10] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC
0.3174  0.001   [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/news/archive' LIMIT 1
0.3185  0.0011  [10] Using template: \templates\navigation\footer_nav.html
0.3224  0.004   [1] SELECT groupID FROM seg_navigation WHERE groupSlug='quicklinks-and-resources' LIMIT 1
0.323   0.0006  [11] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=3 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC
0.324   0.001   [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=3 AND p.pagePath='/news/archive' LIMIT 1
0.325   0.001   [11] Using template: \templates\navigation\footer_nav.html
0.329   0.004   [1] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-03 13:28:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 1
0.3482  0.0192  [1] SELECT FOUND_ROWS() AS `count`
0.3489  0.0007  [1] Using template: \templates\blog\post_in_list.html
0.3498  0.0009  [4] SELECT * FROM seg_categories ORDER BY catTreePosition ASC
0.355   0.0052  [5] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-03 13:28:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 5
0.4521  0.0971  [1] SELECT FOUND_ROWS() AS `count`
0.4537  0.0016  [5] Using template: \templates\blog\post_in_list_footer.html
Time    Δ   Debug Message
0.0447  0   [229] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM seg_pages p LEFT JOIN seg_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
0.0515  0.0069  Matched route: news/category/[slug:cat]/[slug:subcat]
0.0518  0.0002  Using master page: \templates\pages\news\archive.php
0.0518  0   Page arguments:
Array
(
    [0] => /news/category/athletics/baseball
    [cat] => athletics
    [1] => athletics
    [subcat] => baseball
    [2] => baseball
)
0.0569  0.0051  [1] SELECT * FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1
0.0592  0.0024  Using template: \templates\pages\attributes\default.html
0.0603  0.0011  Using sub-template: \templates\pages/attributes/seo.html
0.0616  0.0013  [1] SELECT groupID FROM seg_navigation WHERE groupSlug='informational-navigation' LIMIT 1
0.0621  0.0005  [4] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=1 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.063   0.0009  [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=1 AND p.pagePath='/news/archive' LIMIT 1
0.064   0.001   [4] Using template: \templates\navigation\inform_nav.html
0.0665  0.0025  Using template: \templates\search\search-form.html
0.0695  0.003   [211] SELECT * FROM seg_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC
0.0769  0.0074  [1] SELECT pageTreePosition FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1
0.0774  0.0006  [2] SELECT pageID FROM seg_pages WHERE pageTreePosition IN ('000-009-003', '000-009', '000') ORDER BY pageTreePosition DESC
0.0815  0.0041  Using template: \templates\navigation\main_nav.html
0.082   0.0005  [4] Using template: \templates\navigation\main_navsub.html
0.0839  0.0019  [4] Using template: \templates\navigation\main_navsub.html
0.139   0.0551  [4] Using template: \templates\navigation\main_navsub.html
0.1439  0.0049  [6] Using template: \templates\navigation\main_navsub.html
0.1515  0.0076  [211] SELECT * FROM seg_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC
0.1602  0.0088  [1] SELECT pageTreePosition FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1
0.1612  0.001   [2] SELECT pageID FROM seg_pages WHERE pageTreePosition IN ('000-009-003', '000-009', '000') ORDER BY pageTreePosition DESC
0.1657  0.0044  Using template: \templates\navigation\main_nav2.html
0.1661  0.0004  [4] Using template: \templates\navigation\main_navsub.html
0.168   0.002   [4] Using template: \templates\navigation\main_navsub.html
0.226   0.058   [4] Using template: \templates\navigation\main_navsub.html
0.2312  0.0051  [6] Using template: \templates\navigation\main_navsub.html
0.2416  0.0104  [1] SELECT * FROM seg_categories WHERE catPath='blog/athletics/' LIMIT 1
0.2546  0.013   [4] SELECT DISTINCT idx.itemID FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' AND ((idx.indexKey='_category' AND idx.indexValue LIKE 'blog/athletics/%' OR idx.indexKey='_category' AND idx.indexValue='blog/athletics/'))
0.2567  0.0022  [4] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_blog_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='postDateTime' AND idx.itemID IN ('10', '33', '37', '34') WHERE 1=1 AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-03 13:28:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 10
0.2646  0.0079  [1] SELECT FOUND_ROWS() AS `count`
0.2672  0.0026  [31] SELECT DISTINCT settingID, settingValue FROM seg_settings WHERE userID=0
0.2749  0.0077  [4] Using template: \templates\blog\post_in_list.html
0.2769  0.002   [1] SELECT * FROM seg_blog_sections ORDER BY sectionTitle ASC
0.2788  0.0019  [1] SELECT * FROM seg_blogs ORDER BY blogTitle ASC
0.2798  0.001   [4] SELECT * FROM seg_categories ORDER BY catTreePosition ASC
0.2957  0.0159  [1] SELECT setID FROM seg_category_sets WHERE setSlug='blog' LIMIT 1
0.2964  0.0007  [9] SELECT main.* , COALESCE(cc.countValue,0) AS `count.blog.post` FROM seg_categories main LEFT OUTER JOIN seg_category_counts cc ON cc.catID=main.catID WHERE 1=1 AND setID=11 AND (cc.countType='blog.post' OR cc.countType IS NULL) AND cc.countValue > 0 ORDER BY catTreePosition ASC
0.3014  0.005   [9] Using template: \templates\blog\category_link.html
0.3058  0.0044  [1] SELECT * FROM seg_blogs WHERE blogSlug='blog' LIMIT 1
0.3063  0.0005  [nil] SELECT t.tagTitle, t.tagSlug, COUNT(p2t.postID) AS qty FROM seg_blog_tags t, seg_blog_posts_to_tags p2t, seg_blog_posts p WHERE p2t.tagID=t.tagID AND p2t.postID=p.postID AND p.postStatus='Published' AND p.postDateTime<='2016-10-03 13:28:00' AND p.blogID=1 GROUP BY t.tagID ORDER BY t.tagTitle ASC
0.3071  0.0008  [] Using template: \templates\blog\tag_link.html
0.3073  0.0002  [1] SELECT year(postDateTime) as year, COUNT(*) AS year_qty FROM seg_blog_posts WHERE postStatus='Published' AND postDateTime<='2016-10-03 13:28:00' GROUP BY year ORDER BY year DESC
0.3088  0.0015  Using template: \templates\blog\months_month_link.html
0.309   0.0002  [6] SELECT DISTINCT year(postDateTime) AS year, month(postDateTime) AS month, CONCAT(year(postDateTime),"-",month(postDateTime),"-01") AS postDateTime, COUNT(*) AS month_qty FROM seg_blog_posts p WHERE year(postDateTime) = '2016' AND p.postStatus='Published' AND p.postDateTime<='2016-10-03 13:28:00' GROUP BY year, month ORDER BY month DESC
0.3142  0.0052  [1] Using template: \templates\blog\months_year_link.html
0.3158  0.0017  [1] SELECT groupID FROM seg_navigation WHERE groupSlug='explore-goode' LIMIT 1
0.3164  0.0006  [10] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC
0.3174  0.001   [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/news/archive' LIMIT 1
0.3185  0.0011  [10] Using template: \templates\navigation\footer_nav.html
0.3224  0.004   [1] SELECT groupID FROM seg_navigation WHERE groupSlug='quicklinks-and-resources' LIMIT 1
0.323   0.0006  [11] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=3 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC
0.324   0.001   [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=3 AND p.pagePath='/news/archive' LIMIT 1
0.325   0.001   [11] Using template: \templates\navigation\footer_nav.html
0.329   0.004   [1] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-03 13:28:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 1
0.3482  0.0192  [1] SELECT FOUND_ROWS() AS `count`
0.3489  0.0007  [1] Using template: \templates\blog\post_in_list.html
0.3498  0.0009  [4] SELECT * FROM seg_categories ORDER BY catTreePosition ASC
0.355   0.0052  [5] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-03 13:28:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 5
0.4521  0.0971  [1] SELECT FOUND_ROWS() AS `count`
0.4537  0.0016  [5] Using template: \templates\blog\post_in_list_footer.html
0.4579  0.0042  Request time: 0.4579
0.458   0   Process time: 0.4552
0.458   0   Memory: 3.6643

Thanks

Drew McLellan

Drew McLellan 2638 points
Perch Support

I can see you filtering for athletics but not for baseball. Are you using perch_get('subcat') in your filter at all?

No, I actually was not using perch_get('subcat') in my archive.php file. I went ahead and modified my 'Posts by Category' section to:

/* --------------------------- POSTS BY CATEGORY --------------------------- */
            if (perch_get('cat')) {

                if(perch_get('subcat')) {

                    echo '<h1 class="bred"><small>Archive of:</small> '.perch_blog_category(perch_get('subcat'), true).'</h1>';
                    perch_blog_custom(array(
                            'category'   => perch_get('cat').'/'.perch_get('subcat'),
                            'template'   => $template,
                            'count'      => $posts_per_page,
                            'sort'       => $sort_by,
                            'sort-order' => $sort_order,
                            ));
                    $posts_displayed = true;

                } else {

                    echo '<h1 class="bred"><small>Archive of:</small> '.perch_blog_category(perch_get('cat'), true).'</h1>';
                    perch_blog_custom(array(
                            'category'   => perch_get('cat'),
                            'template'   => $template,
                            'count'      => $posts_per_page,
                            'sort'       => $sort_by,
                            'sort-order' => $sort_order,
                            ));
                    $posts_displayed = true;

                }

            }

Unfortunately, now what I see happening is that my categories (athletics) are working, but my subcategories (athletics/baseball) are not displaying results.

I also noticed that in my category links, I see athletics listed with a count.blog.post value of 1. This value is correct, but I'm getting the posts for athletics and all subcategories of athletics though...a bit confusing.

Here is my updated debug output:


Time Δ Debug Message 0.0455 0 [229] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM seg_pages p LEFT JOIN seg_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC 0.0512 0.0056 Matched route: news/category/[slug:cat]/[slug:subcat] 0.0513 0.0002 Using master page: \templates\pages\news\archive.php 0.0514 0 Page arguments: Array ( [0] => /news/category/athletics/baseball [cat] => athletics [1] => athletics [subcat] => baseball [2] => baseball ) 0.0568 0.0054 [1] SELECT * FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1 0.0591 0.0023 Using template: \templates\pages\attributes\default.html 0.0603 0.0013 Using sub-template: \templates\pages/attributes/seo.html 0.0616 0.0013 [1] SELECT groupID FROM seg_navigation WHERE groupSlug='informational-navigation' LIMIT 1 0.0621 0.0005 [4] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=1 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC 0.0628 0.0008 [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=1 AND p.pagePath='/news/archive' LIMIT 1 0.0635 0.0007 [4] Using template: \templates\navigation\inform_nav.html 0.0661 0.0025 Using template: \templates\search\search-form.html 0.0691 0.003 [211] SELECT * FROM seg_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC 0.077 0.0079 [1] SELECT pageTreePosition FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1 0.0776 0.0006 [2] SELECT pageID FROM seg_pages WHERE pageTreePosition IN ('000-009-003', '000-009', '000') ORDER BY pageTreePosition DESC 0.0813 0.0037 Using template: \templates\navigation\main_nav.html 0.0817 0.0004 [4] Using template: \templates\navigation\main_navsub.html 0.0838 0.0021 [4] Using template: \templates\navigation\main_navsub.html 0.135 0.0513 [4] Using template: \templates\navigation\main_navsub.html 0.1397 0.0046 [6] Using template: \templates\navigation\main_navsub.html 0.1474 0.0077 [211] SELECT * FROM seg_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC 0.1559 0.0085 [1] SELECT pageTreePosition FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1 0.1573 0.0014 [2] SELECT pageID FROM seg_pages WHERE pageTreePosition IN ('000-009-003', '000-009', '000') ORDER BY pageTreePosition DESC 0.1614 0.0041 Using template: \templates\navigation\main_nav2.html 0.1618 0.0004 [4] Using template: \templates\navigation\main_navsub.html 0.1638 0.002 [4] Using template: \templates\navigation\main_navsub.html 0.2225 0.0587 [4] Using template: \templates\navigation\main_navsub.html 0.2288 0.0063 [6] Using template: \templates\navigation\main_navsub.html 0.2417 0.0129 [1] SELECT * FROM seg_categories WHERE catPath='blog/baseball/' LIMIT 1 0.2467 0.005 [0] SELECT DISTINCT idx.itemID FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' AND ((idx.indexKey='_category' AND idx.indexValue LIKE 'athletics/baseball%' OR idx.indexKey='_category' AND idx.indexValue='athletics/baseball')) 0.2493 0.0026 [nil] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-04 09:48:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 10 0.2513 0.002 [1] SELECT FOUND_ROWS() AS `count` 0.2531 0.0018 [31] SELECT DISTINCT settingID, settingValue FROM seg_settings WHERE userID=0 0.2665 0.0134 Using template: \templates\blog\post_in_list.html 0.2677 0.0013 [1] SELECT setID FROM seg_category_sets WHERE setSlug='blog' LIMIT 1 0.2685 0.0008 [9] SELECT main.* , COALESCE(cc.countValue,0) AS `count.blog.post` FROM seg_categories main LEFT OUTER JOIN seg_category_counts cc ON cc.catID=main.catID WHERE 1=1 AND setID=11 AND (cc.countType='blog.post' OR cc.countType IS NULL) AND cc.countValue > 0 ORDER BY catTreePosition ASC 0.2747 0.0062 [9] Using template: \templates\blog\category_link.html 0.2789 0.0042 [1] SELECT * FROM seg_blogs WHERE blogSlug='blog' LIMIT 1 0.2804 0.0015 [nil] SELECT t.tagTitle, t.tagSlug, COUNT(p2t.postID) AS qty FROM seg_blog_tags t, seg_blog_posts_to_tags p2t, seg_blog_posts p WHERE p2t.tagID=t.tagID AND p2t.postID=p.postID AND p.postStatus='Published' AND p.postDateTime<='2016-10-04 09:48:00' AND p.blogID=1 GROUP BY t.tagID ORDER BY t.tagTitle ASC 0.2828 0.0024 [] Using template: \templates\blog\tag_link.html 0.283 0.0002 [1] SELECT year(postDateTime) as year, COUNT(*) AS year_qty FROM seg_blog_posts WHERE postStatus='Published' AND postDateTime<='2016-10-04 09:48:00' GROUP BY year ORDER BY year DESC 0.2851 0.0021 Using template: \templates\blog\months_month_link.html 0.2852 0.0001 [6] SELECT DISTINCT year(postDateTime) AS year, month(postDateTime) AS month, CONCAT(year(postDateTime),"-",month(postDateTime),"-01") AS postDateTime, COUNT(*) AS month_qty FROM seg_blog_posts p WHERE year(postDateTime) = '2016' AND p.postStatus='Published' AND p.postDateTime<='2016-10-04 09:48:00' GROUP BY year, month ORDER BY month DESC 0.292 0.0068 [1] Using template: \templates\blog\months_year_link.html 0.2937 0.0016 [1] SELECT groupID FROM seg_navigation WHERE groupSlug='explore-goode' LIMIT 1 0.2946 0.001 [10] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC 0.2959 0.0013 [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/news/archive' LIMIT 1 0.2978 0.0019 [10] Using template: \templates\navigation\footer_nav.html 0.3026 0.0048 [1] SELECT groupID FROM seg_navigation WHERE groupSlug='quicklinks-and-resources' LIMIT 1 0.305 0.0024 [11] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=3 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC 0.3069 0.0019 [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=3 AND p.pagePath='/news/archive' LIMIT 1 0.3094 0.0025 [11] Using template: \templates\navigation\footer_nav.html 0.3137 0.0043 [1] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-04 09:48:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 1 0.3661 0.0524 [1] SELECT FOUND_ROWS() AS `count` 0.3687 0.0026 [1] Using template: \templates\blog\post_in_list.html 0.3708 0.0021 [1] SELECT * FROM seg_blog_sections ORDER BY sectionTitle ASC 0.3722 0.0013 [1] SELECT * FROM seg_blogs ORDER BY blogTitle ASC 0.3731 0.0009 [4] SELECT * FROM seg_categories ORDER BY catTreePosition ASC 0.3788 0.0057 [5] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-04 09:48:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 5 0.3912 0.0124 [1] SELECT FOUND_ROWS() AS `count` 0.3922 0.001 [5] Using template: \templates\blog\post_in_list_footer.html Time Δ Debug Message 0.0455 0 [229] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM seg_pages p LEFT JOIN seg_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC 0.0512 0.0056 Matched route: news/category/[slug:cat]/[slug:subcat] 0.0513 0.0002 Using master page: \templates\pages\news\archive.php 0.0514 0 Page arguments: Array ( [0] => /news/category/athletics/baseball [cat] => athletics [1] => athletics [subcat] => baseball [2] => baseball ) 0.0568 0.0054 [1] SELECT * FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1 0.0591 0.0023 Using template: \templates\pages\attributes\default.html 0.0603 0.0013 Using sub-template: \templates\pages/attributes/seo.html 0.0616 0.0013 [1] SELECT groupID FROM seg_navigation WHERE groupSlug='informational-navigation' LIMIT 1 0.0621 0.0005 [4] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=1 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC 0.0628 0.0008 [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=1 AND p.pagePath='/news/archive' LIMIT 1 0.0635 0.0007 [4] Using template: \templates\navigation\inform_nav.html 0.0661 0.0025 Using template: \templates\search\search-form.html 0.0691 0.003 [211] SELECT * FROM seg_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC 0.077 0.0079 [1] SELECT pageTreePosition FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1 0.0776 0.0006 [2] SELECT pageID FROM seg_pages WHERE pageTreePosition IN ('000-009-003', '000-009', '000') ORDER BY pageTreePosition DESC 0.0813 0.0037 Using template: \templates\navigation\main_nav.html 0.0817 0.0004 [4] Using template: \templates\navigation\main_navsub.html 0.0838 0.0021 [4] Using template: \templates\navigation\main_navsub.html 0.135 0.0513 [4] Using template: \templates\navigation\main_navsub.html 0.1397 0.0046 [6] Using template: \templates\navigation\main_navsub.html 0.1474 0.0077 [211] SELECT * FROM seg_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC 0.1559 0.0085 [1] SELECT pageTreePosition FROM seg_pages WHERE pagePath='/news/archive' LIMIT 1 0.1573 0.0014 [2] SELECT pageID FROM seg_pages WHERE pageTreePosition IN ('000-009-003', '000-009', '000') ORDER BY pageTreePosition DESC 0.1614 0.0041 Using template: \templates\navigation\main_nav2.html 0.1618 0.0004 [4] Using template: \templates\navigation\main_navsub.html 0.1638 0.002 [4] Using template: \templates\navigation\main_navsub.html 0.2225 0.0587 [4] Using template: \templates\navigation\main_navsub.html 0.2288 0.0063 [6] Using template: \templates\navigation\main_navsub.html 0.2417 0.0129 [1] SELECT * FROM seg_categories WHERE catPath='blog/baseball/' LIMIT 1 0.2467 0.005 [0] SELECT DISTINCT idx.itemID FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' AND ((idx.indexKey='_category' AND idx.indexValue LIKE 'athletics/baseball%' OR idx.indexKey='_category' AND idx.indexValue='athletics/baseball')) 0.2493 0.0026 [nil] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-04 09:48:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 10 0.2513 0.002 [1] SELECT FOUND_ROWS() AS `count` 0.2531 0.0018 [31] SELECT DISTINCT settingID, settingValue FROM seg_settings WHERE userID=0 0.2665 0.0134 Using template: \templates\blog\post_in_list.html 0.2677 0.0013 [1] SELECT setID FROM seg_category_sets WHERE setSlug='blog' LIMIT 1 0.2685 0.0008 [9] SELECT main.* , COALESCE(cc.countValue,0) AS `count.blog.post` FROM seg_categories main LEFT OUTER JOIN seg_category_counts cc ON cc.catID=main.catID WHERE 1=1 AND setID=11 AND (cc.countType='blog.post' OR cc.countType IS NULL) AND cc.countValue > 0 ORDER BY catTreePosition ASC 0.2747 0.0062 [9] Using template: \templates\blog\category_link.html 0.2789 0.0042 [1] SELECT * FROM seg_blogs WHERE blogSlug='blog' LIMIT 1 0.2804 0.0015 [nil] SELECT t.tagTitle, t.tagSlug, COUNT(p2t.postID) AS qty FROM seg_blog_tags t, seg_blog_posts_to_tags p2t, seg_blog_posts p WHERE p2t.tagID=t.tagID AND p2t.postID=p.postID AND p.postStatus='Published' AND p.postDateTime<='2016-10-04 09:48:00' AND p.blogID=1 GROUP BY t.tagID ORDER BY t.tagTitle ASC 0.2828 0.0024 [] Using template: \templates\blog\tag_link.html 0.283 0.0002 [1] SELECT year(postDateTime) as year, COUNT(*) AS year_qty FROM seg_blog_posts WHERE postStatus='Published' AND postDateTime<='2016-10-04 09:48:00' GROUP BY year ORDER BY year DESC 0.2851 0.0021 Using template: \templates\blog\months_month_link.html 0.2852 0.0001 [6] SELECT DISTINCT year(postDateTime) AS year, month(postDateTime) AS month, CONCAT(year(postDateTime),"-",month(postDateTime),"-01") AS postDateTime, COUNT(*) AS month_qty FROM seg_blog_posts p WHERE year(postDateTime) = '2016' AND p.postStatus='Published' AND p.postDateTime<='2016-10-04 09:48:00' GROUP BY year, month ORDER BY month DESC 0.292 0.0068 [1] Using template: \templates\blog\months_year_link.html 0.2937 0.0016 [1] SELECT groupID FROM seg_navigation WHERE groupSlug='explore-goode' LIMIT 1 0.2946 0.001 [10] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC 0.2959 0.0013 [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/news/archive' LIMIT 1 0.2978 0.0019 [10] Using template: \templates\navigation\footer_nav.html 0.3026 0.0048 [1] SELECT groupID FROM seg_navigation WHERE groupSlug='quicklinks-and-resources' LIMIT 1 0.305 0.0024 [11] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM seg_navigation_pages np, seg_pages p WHERE p.pageID=np.pageID AND np.groupID=3 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC 0.3069 0.0019 [0] SELECT np.pageTreePosition FROM seg_pages p, seg_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=3 AND p.pagePath='/news/archive' LIMIT 1 0.3094 0.0025 [11] Using template: \templates\navigation\footer_nav.html 0.3137 0.0043 [1] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-04 09:48:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 1 0.3661 0.0524 [1] SELECT FOUND_ROWS() AS `count` 0.3687 0.0026 [1] Using template: \templates\blog\post_in_list.html 0.3708 0.0021 [1] SELECT * FROM seg_blog_sections ORDER BY sectionTitle ASC 0.3722 0.0013 [1] SELECT * FROM seg_blogs ORDER BY blogTitle ASC 0.3731 0.0009 [4] SELECT * FROM seg_categories ORDER BY catTreePosition ASC 0.3788 0.0057 [5] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM seg_blog_index idx JOIN seg_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN seg_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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-10-04 09:48:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 5 0.3912 0.0124 [1] SELECT FOUND_ROWS() AS `count` 0.3922 0.001 [5] Using template: \templates\blog\post_in_list_footer.html 0.3972 0.005 Request time: 0.3971 0.3972 0 Process time: 0.3935 0.3973 0.0001 Memory: 3.6657
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are these still in the blog set? If so:

'category' => 'blog/'.perch_get('cat').'/'.perch_get('subcat'),

Yes, that worked! Thanks Drew!

For my athletics category though, I'm still getting the posts of all its subcategories included in the results.

This actually makes sense and I wouldn't have a problem with it, except that the count.blog.post value from athletics is displaying 1. The value is not wrong, as I do only have 1 post categorized under athletics, but if the results are going to include all the athletics subcategories too, then it's confusing.

The posts that are categorized in subcategories of athletics are not categorized in the athletics category. So are they still being included because I'm using cat for both routes?

blog/category/[slug:cat]
blog/category/[slug:cat]/[slug:subcat]

Is cat a default or can I change it?

I'm thinking if the subcategories are being included because cat is being used for both routes, then could I change the second route to something like this for example?

blog/category/[slug:cats]/[slug:subcat]
Drew McLellan

Drew McLellan 2638 points
Perch Support

It's just a label - you can change it to whatever you want.

Ok great. Thanks for all your help Drew!