Forum

Thread tagged as: Problem, Addons, Blog

show blog categories for one blog from multiple blogs

When I try to display a list of categories from a single blog Perch Runway is returning all categories from the multiple blogs I have setup. What am I doing wrong?

I'm using this:

           perch_blog_categories(array(
                'blog' => 'faqs',
               'cache' => false,
           ));

Help appreciated

Graham Shedden

Graham Shedden 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

If you turn on debug, what does it output?

Updated.

Debug Message - Perch Runway 3.0.11
[238] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID LEFT JOIN perch2_settings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM perch2_page_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
Matched page: /support/faqs, so not using routes.
Using master page: /templates/pages/FAQ/faq.php
[36] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[27] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/support/faqs' OR regionPage='*' ORDER BY regionPage DESC
[1] SELECT * FROM perch2_pages WHERE pagePath='/support/faqs' LIMIT 1
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
[1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/en' OR pageSortPath='/en' LIMIT 1
[152] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/support/faqs' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-013-010', '000-013', '000') ORDER BY pageTreePosition DESC
Using template: /templates/navigation/main-nav-bs.html
[10] Using template: /templates/navigation/main-nav-level2-bs.html
[9] Using template: /templates/navigation/main-nav-level2-bs.html
[9] Using template: /templates/navigation/main-nav-level2-bs.html
[6] Using template: /templates/navigation/main-nav-level2-bs.html
[7] Using template: /templates/navigation/main-nav-level2-bs.html
[1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/support/faqs' OR pageSortPath='/support/faqs' LIMIT 1
[1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pageTreePosition='000-013' LIMIT 1
[7] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-013%' AND pageDepth >=1 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/support/faqs' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-013-010', '000-013', '000') ORDER BY pageTreePosition DESC
[6] Using template: /templates/navigation/section-nav-1-bs.html
[3] 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 'blog/recommended-articles/%' OR idx.indexKey='_category' AND idx.indexValue='blog/recommended-articles/'))
[1] SELECT blogID FROM perch2_blogs WHERE blogSlug='faqs' LIMIT 1
[3] 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 ('67', '70', '71') WHERE 1=1 AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID, idx2.indexValue, postID ) as tbl WHERE ( blogID=2 AND postStatus='Published' AND postDateTime<='2018-08-26 20:18:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 8
[1] SELECT FOUND_ROWS() AS `count`
[3] Using template: /templates/blog/recommended_in_list.html
[7] SELECT * FROM perch2_blog_sections ORDER BY sectionTitle ASC
[2] SELECT * FROM perch2_blogs ORDER BY blogTitle ASC
[1] SELECT * FROM perch2_categories ORDER BY catTreePosition ASC
[1] SELECT * FROM perch2_blogs WHERE blogSlug='faqs' LIMIT 1
[4] SELECT *, sectionID AS _id, sectionPostCount as qty FROM perch2_blog_sections WHERE 1=1 AND blogID=2 ORDER BY sectionTitle ASC
[4] Using template: /templates/blog/section_list_faqs.html
[1] SELECT * FROM perch2_blogs WHERE blogSlug='faqs' LIMIT 1
[1] SELECT setID FROM perch2_category_sets WHERE setSlug='blog' LIMIT 1
[3] 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 setID=25 AND (cc.countType='blog.post' OR cc.countType IS NULL) AND cc.countValue > 0 ORDER BY catTreePosition ASC
[3] Using template: /templates/blog/category_list.html
[1] SELECT groupID FROM perch2_navigation WHERE groupSlug='footer' LIMIT 1
[5] 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 perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=1 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC
[0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=1 AND p.pagePath='/support/faqs' LIMIT 1
[5] Using template: /templates/navigation/footer.html
[1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/about-us' OR pageSortPath='/about-us' LIMIT 1
[11] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-005%' AND pageDepth >=1 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/support/faqs' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-013-010', '000-013', '000') ORDER BY pageTreePosition DESC
Using template: /templates/navigation/item.html
[1] Using template: /templates/navigation/item_2.html
[1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/news' OR pageSortPath='/news' LIMIT 1
[1] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-010%' AND pageDepth >=1 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/support/faqs' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-013-010', '000-013', '000') ORDER BY pageTreePosition DESC
[1] Template file not found: /home/tf2cl2ny/powerjacks.alienpixel.uk/perch/templates/navigation/.html
[1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/products' OR pageSortPath='/products' LIMIT 1
[10] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-006%' AND pageDepth >=1 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/support/faqs' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-013-010', '000-013', '000') ORDER BY pageTreePosition DESC
[1] Using template: /templates/navigation/item_2.html
[1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/services' OR pageSortPath='/services' LIMIT 1
[8] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-007%' AND pageDepth >=1 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/support/faqs' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-013-010', '000-013', '000') ORDER BY pageTreePosition DESC
[1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/industries' OR pageSortPath='/industries' LIMIT 1
[7] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-009%' AND pageDepth >=1 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/support/faqs' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-013-010', '000-013', '000') ORDER BY pageTreePosition DESC
[1] Using template: /templates/navigation/item_2.html
[1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/where-to-buy' OR pageSortPath='/where-to-buy' LIMIT 1
[1] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-011%' AND pageDepth >=1 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/support/faqs' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-013-010', '000-013', '000') ORDER BY pageTreePosition DESC
[1] Using template: /templates/navigation/item_2.html
[1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/downloads-videos' OR pageSortPath='/downloads-videos' LIMIT 1
[10] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-008%' AND pageDepth >=1 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/support/faqs' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-013-010', '000-013', '000') ORDER BY pageTreePosition DESC
[1] Using template: /templates/navigation/item_2.html
[1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/support' OR pageSortPath='/support' LIMIT 1
[7] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-013%' AND pageDepth >=1 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/support/faqs' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-013-010', '000-013', '000') ORDER BY pageTreePosition DESC
[1] Using template: /templates/navigation/item_2.html
Request time: 0.1103
Process time: 0.1101
Memory: 6.0794
Drew McLellan

Drew McLellan 2638 points
Perch Support

I can't see it querying categories at all - are you sure the above code is on the page the debug comes from?

I've edited the debug message with the output from the right page this time (sorry).

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, it doesn't look like it's correctly filtering by blog. I can see it looking up which blog to filter by, but with no evidence of that being correctly used.

On the page I'm calling:

<?php
   perch_blog_categories(array(
        'blog' => 'faqs',
    'cache' => false,
    'template' => 'category_list.html',
    ));    
?>

on the template 'category_list.html'

<perch:before>
<h3>Categories</h3>
<ul class="list-group">
</perch:before>
    <perch:if id="visible" value="0" match="eq">
        <li class="list-group-item">
        <a href="/news/category/<perch:category id="catSlug" type="slug" />">
            <perch:category id="catTitle" type="smarttext" />   
        </a>
    </li>
    </perch:if>
<perch:after></ul></perch:after>

The second blog was added at a later date. Could there be some residual data in the database that's having an affect?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No I don't think so. It just looks like a bug.