Forum

Thread tagged as: Problem, Installation, Addons

perch_blog_categories() not showing

Hi,

I have a site which was created a few years ago and has now had the core updated and I'm now updating the addons so that they are compatible, but I'm running into a couple of issues.

With the updated blog I am struggling with the new method of displaying categories. I've added the new categories app template files and added to my apps config file, so I'm sure everything is okay there, but when I use <?php perch_blog_categories(); ?> on a blog page, nothing is displayed.

On the original site, I installed the blog twice because my client wanted a blog and also a way of displaying a large variety of plants with custom fields and categorised by type and in where they sit in the alphabet, so I did a find and replace through the blog app replacing blog with "plant cats" and post with "plant", making sure this was constant with files and folders and this all worked fine. I've done the same here, and it seems to be okay again, but on neither app can I workout how to filter categories or display links to them.

Probably it's easiest to start with the blog app, because if I can work this out, I could workout what's gone wrong with the other?

Here is my diagnostics:

SUMMARY INFORMATION

Perch: 2.8.25, PHP: 5.6.10, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $, with PDO Server OS: Darwin, apache2handler Installed apps: content (2.8.25), assets (2.8.25), categories (2.8.25), perch_blog (5.0), perch_events (1.7), perch_mailchimp (2.0.1), perch_plantcats (5.0), perch_shop_paypal (1.2.3) App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_plantcats', 'perch_shop_paypal', 'perch_events', 'perch_blog', 'perch_mailchimp', ); PERCH_LOGINPATH: /admin PERCH_PATH: /Users/alexbennett/Desktop/Job Folder/Cooks Lane Herbs/Test-website/admin PERCH_CORE: /Users/alexbennett/Desktop/Job Folder/Cooks Lane Herbs/Test-website/admin/core PERCH_RESFILEPATH: /Users/alexbennett/Desktop/Job Folder/Cooks Lane Herbs/Test-website/admin/resources Image manipulation: GD PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M F1: dc1fef2ad0fcd9f943c02ebb43d85dbc Resource folder writeable: Yes HTTP_HOST: cookslaneherbs:8888 DOCUMENT_ROOT: /Users/alexbennett/Desktop/Job Folder/Cooks Lane Herbs/Test-website REQUEST_URI: /admin/core/settings/diagnostics/ SCRIPT_NAME: /admin/core/settings/diagnostics/index.php

Alex Bennett

Alex Bennett 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

When you use perch_blog_categories(), what does the debug output on the page?

We can't help you with hacked versions of our add ons.

Hi Drew - thanks for getting back to me.

Completely understand about the hacked plugin - I wanted to mention it because it would show up in the diagnostic.

RE the debug, when using perch_blog_categories() I get the following:

Debug Message [1] SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='40e3e12519998a80383402994d99a801' LIMIT 1 UPDATE perch2_users SET userHash='25c40ba7197e6b4ade22bb5cbeba1e87' WHERE userID='1' [56] SELECT p.privKey FROM perch2_user_privileges p [38] SELECT * FROM (SELECT DISTINCT settingID, settingValue, userID FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID, settingValue, userID [nil] SELECT *, REPLACE(pagePath, '/index.php', '') as sortPath FROM perch2_pages WHERE pageNew=1 ORDER BY LENGTH(sortPath)-LENGTH(REPLACE(sortPath, '/', '')) ASC [13] SELECT p.*, (SELECT COUNT() FROM perch2_pages WHERE pageParentID=p.pageID) AS subpages FROM perch2_pages p WHERE p.pageParentID IN (0) ORDER BY p.pageTreePosition ASC [27] SELECT * FROM perch2_content_regions ORDER BY regionOrder ASC [9] SELECT * FROM perch2_content_regions WHERE regionPage='' [11] SELECT DISTINCT regionTemplate FROM perch2_content_regions ORDER BY regionTemplate ASC Queries: 10 Memory: 2.7021

I added the debug output to the page, so maybe this is more useful?:

Debug Message
[1] SELECT * FROM perch2_pages WHERE pagePath='/blog/index.php' LIMIT 1
[9] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/blog/index.php' OR regionPage='*' ORDER BY regionPage DESC
Fetching from cache: perch_blog_categories589c7a634eb12f2ec225cfedc7dc78ae
Cache file not found: perch_blog_categories589c7a634eb12f2ec225cfedc7dc78ae
[1] SELECT setID FROM perch2_category_sets WHERE setSlug='blog' LIMIT 1
[nil] 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=2 AND (cc.countType='blog.post' OR cc.countType IS NULL) AND cc.countValue > 0 ORDER BY catTreePosition ASC
[38] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
Using template: /addons/apps/perch_blog/templates/blog/category_link.html
[10] 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, idx2.indexValue ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-03-13 15:11:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 10
[1] SELECT FOUND_ROWS() AS `count`
[10] Using template: /templates/blog/post_in_list.html
[1] SELECT * FROM perch2_blog_sections ORDER BY sectionTitle ASC
[1] SELECT * FROM perch2_blogs ORDER BY blogTitle ASC
Drew McLellan

Drew McLellan 2638 points
Perch Support

When you upgraded the Blog app, did you see it run through updating the posts 10 at a time?

If you click Save on a post, do its categories then list?

Hi Drew - yes I tried this and you're right it started outputting the one I re-saved. I'll have to go through and re-save the others.

I've been thinking about the hacked one and I cannot imagine what I was thinking when I first did that a couple of years back. I'm going to move all the categories into the blog and manage it by only outputting certain categories on certain pages, so in future there should only be on legit app to update.

Realise now I've created myself a ton of work!!

I've now started putting new categories into the blog app, but I cannot display all of them.

So I have the Set called Blog, and under this 2 categories, one with three sub-categories, as follows:

Blog

Plants:

  • Traditional
  • Culinary
  • Bee Friendly

When I display on my blog index page the list of categories using

<?php perch_blog_categories(); ?>

On my page it shows:

Blog (54) Traditional (1) Culinary (1) Bee Friendly (1)

When I click the blog link it works fine showing the url: https://cookslaneherbs.co.uk/blog/archive.php?cat=blog

...and displays all the relevant posts.

When I click on the other three links, for example Traditional, with the url https://cookslaneherbs.co.uk/blog/archive.php?cat=traditional

...It shows a blank page (the "Archive of:" is there but not the category name).

Do you have an idea what might be wrong?

Thanks

|******** UPDATE ***********|

The problem just affects sub-categories - when putting a post into another top-level category that works fine, but the sub-category posts will not appear on an archive page.

Drew McLellan

Drew McLellan 2638 points
Perch Support

For sub categories, are you specifying the category path? Just the slug alone won't work.

So should the url be saying something more like:

https://cookslaneherbs.co.uk/blog/archive.php?cat=plant/traditional

Drew McLellan

Drew McLellan 2638 points
Perch Support

More like blog/plant/traditional I think.