Forum
perch_blog_custom category filter not working
Hi
I'm having a problem getting my blog posts to filter based on the category. I set up my category set and add "News" and "Events" and then add my blog posts to the "News" category but it shows nothing. Removing the category line shows the content fine. So I'm a little stumped. Diagnostics, Debug and Code below...
Page Code
<?php
perch_blog_custom(array(
'count' => 5,
'template' => 'post_in_list_home_news.html',
'sort' => 'postDateTime',
'sort-order' => 'DESC',
'category' => array('news')
));
?>
Template Code
<perch:before>
</perch:before>
<div class="row">
<div class="large-6 medium-12 small-12 columns">
<a href="<perch:blog id="postURL" />">
<perch:if exists="image">
<img src="<perch:blog id="image" type="image" width="472" height="293" crop="true" />" alt="<perch:blog id="postTitle" />" />
</perch:if>
</a>
</div>
<div class="large-6 medium-12 small-12 columns">
<h4><a href="<perch:blog id="postURL" />" rel="bookmark" class="entry-title"><perch:blog id="postTitle" /></a></h4>
<p class="date"><perch:blog id="postDateTime" format="%d %B %Y" /></p>
</div>
</div>
<perch:after>
</perch:after>
Debug Message
[16] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
Matched page: /news-events, so not using routes.
Using master page: /templates/pages/news-events/index.php
[1] SELECT * FROM perch2_pages WHERE pagePath='/news-events' LIMIT 1
[2] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/news-events' OR regionPage='*' ORDER BY regionPage DESC
Using template: /templates/pages/attributes/seo.html
Using template: /templates/pages/attributes/body_attributes.html
[4] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/news-events' LIMIT 1
[1] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-004', '000') ORDER BY pageTreePosition DESC
[4] Using template: /templates/navigation/main-nav-item.html
[1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Heading' AND (regionPage='/news-events' OR regionPage='*')
[1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=31 AND idx.itemRev=3)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
[1] Using template: /templates/content/global/_heading_top.html
Fetching from cache: perch_blog_categories589c7a634eb12f2ec225cfedc7dc78ae
[1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=31 AND idx.itemRev=3)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
[1] Using template: /templates/content/global/_heading_bottom.html
[0] 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/news/%' OR idx.indexKey='_category' AND idx.indexValue='blog/news/'))
[nil] 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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2017-01-31 09:46:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 5
[1] SELECT FOUND_ROWS() AS `count`
[28] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
Using template: /templates/blog/post_in_list_home_news.html
[1] 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 ) as tbl WHERE (postStatus='Published' AND postDateTime<='2017-01-31 09:46:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 5
[1] SELECT FOUND_ROWS() AS `count`
[1] Using template: /templates/blog/post_in_list_home_events.html
[1] SELECT * FROM perch2_blog_sections ORDER BY sectionTitle ASC
[1] SELECT * FROM perch2_blogs ORDER BY blogTitle ASC
[1] SELECT groupID FROM perch2_navigation WHERE groupSlug='footer-navigation' LIMIT 1
[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 perch2_navigation_pages np, perch2_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
[1] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=1 AND p.pagePath='/news-events' LIMIT 1
[1] SELECT pageID FROM perch2_navigation_pages WHERE groupID=1 AND pageTreePosition IN ('000-004', '000') ORDER BY pageTreePosition DESC
[4] Using template: /templates/navigation/item.html
Request time: 0.652
Process time: 0.651
Memory: 3.9627
Diagnostics
Perch Runway: 2.8.34
Production mode: Production (100)
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_blog (5.0), perch_forms (1.8.3), perch_members (1.5), perch_mailchimp (3.0.1)
DB driver: PDO
DB tables: perch2_backup_plans (0), perch2_backup_resources (0), perch2_backup_runs (0), perch2_blog_authors (1), perch2_blog_comments (0), perch2_blog_index (24), perch2_blog_posts (1), perch2_blog_posts_to_tags (0), perch2_blog_sections (1), perch2_blog_tags (0), perch2_blogs (1), perch2_categories (2), perch2_category_counts (1), perch2_category_sets (1), perch2_collection_index (0), perch2_collection_items (0), perch2_collection_revisions (0), perch2_collections (0), perch2_content_index (419), perch2_content_items (59), perch2_content_regions (25), perch2_forms (0), perch2_forms_responses (0), perch2_mailchimp_campaigns (0), perch2_mailchimp_imports (1), perch2_mailchimp_lists (0), perch2_mailchimp_subscribers (0), perch2_mailchimp_subscriptions (0), perch2_mailchimp_webhooks (0), perch2_members (1), perch2_members_forms (1), perch2_members_member_tags (0), perch2_members_sessions (1), perch2_members_tags (0), perch2_navigation (1), perch2_navigation_pages (5), perch2_page_routes (1), perch2_page_templates (15), perch2_pages (16), perch2_resource_log (29), perch2_resource_tags (0), perch2_resources (7), perch2_resources_to_tags (0), perch2_settings (28), perch2_user_passwords (0), perch2_user_privileges (41), perch2_user_role_privileges (16), perch2_user_roles (2), perch2_users (1)
Users: 1
PHPMailer: 5.2.21
App runtimes:
<?php
$apps_list = array(
'content',
'categories',
'perch_blog',
'perch_forms',
'perch_members',
'perch_mailchimp',
);
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Scheduled tasks for perch_mailchimp: import_data (1 mins)
Editor plug-ins: markitup
H1: f50057538d38d1d190d572a606a70f90
L1: 7f6df168a1797e496a59860fd83599a7
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
headerColour: #20a7ff
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.34: done
headerScheme: dark
update_runway_2.8.34: done
latest_version: 2.8.15
on_sale_version: 2.8.34
perch_blog_site_name: AceForm4.0
perch_blog_post_url: /news-events/{postSlug}
perch_blog_slug_format: %Y-%m-%d-{postTitle}
perch_blog_akismet_key:
perch_blog_max_spam_days: 0
perch_mailchimp_campaign_url: /mailchimp/campaign/{campaignSlug}
perch_members_login_page: /members/login.php?r={returnURL}
dashboard: 0
hide_pwd_reset: 0
content_hideNonEditableRegions: 1
content_frontend_edit: 0
perch_blog_comment_notify: 0
perch_members_update: 1.4
perch_blog_update: 5.0.1
perch_mailchimp_api_key: 685e28725493d701c124e702497d3947-us2
perch_mailchimp_secret: 53cbc6c
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_SITEPATH: /
PERCH_SCHEDULE_SECRET: zRFUJ0npAlRlkaKi
PERCH_DB_USERNAME: formulat_admin
PERCH_DB_SERVER: 91.208.99.2:1173
PERCH_DB_DATABASE: formulat_perch
PERCH_DB_PREFIX: perch2_
PERCH_EMAIL_FROM: info@formulation-network.eu
PERCH_EMAIL_FROM_NAME: AceForm4.0
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/danlee/Sites/Work/aceform4-0/perch
PERCH_CORE: /Users/danlee/Sites/Work/aceform4-0/perch/core
PERCH_RESFILEPATH: /Users/danlee/Sites/Work/aceform4-0/perch/resources
PERCH_RESPATH: /perch/resources
PERCH_HTML5: 1
PERCH_TZ: Europe/London
PERCH_EMAIL_METHOD: smtp
PERCH_EMAIL_HOST: mail3.gridhost.co.uk
PERCH_EMAIL_AUTH: 1
PERCH_EMAIL_SECURE: ssl
PERCH_EMAIL_PORT: 465
PERCH_EMAIL_USERNAME: info@formulation-network.eu
PERCH_YOUTUBE_API_KEY: AIzaSyABObR78cRpeVORGJkYkKEAclJodKiURcE
PERCH_GMAPS_API_KEY: AIzaSyCd5Gr9pQ-SA7XuYkG7CS9dqXzdpfRfG0I
PERCH_DEBUG: 1
PERCH_RUNWAY: 1
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /Users/danlee/Sites/Work/aceform4-0/perch/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_PRODUCTION_MODE: 100
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
HOSTING SETTINGS
PHP: 7.0.11
Zend: 3.0.0
OS: Darwin
SAPI: apache2handler
Safe mode: not detected
MySQL client: mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $
MySQL server: 5.7.17
Free disk space: 581.41 GB
Extensions: Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, dom, hash, fileinfo, filter, ftp, gd, gettext, SPL, iconv, json, ldap, mbstring, session, standard, mysqlnd, PDO, pdo_mysql, pdo_sqlite, Phar, posix, Reflection, mysqli, shmop, SimpleXML, soap, sockets, exif, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, zip, apache2handler, apcu, curl, gmp, imap, intl, mcrypt, pdo_pgsql, pgsql, propro, raphf, readline, xsl, http, Zend OPcache, xdebug
GD: Yes
ImageMagick: No
PHP max upload size: 50M
PHP max form post size: 60M
PHP memory limit: 256M
Total max uploadable file size: 50M
Resource folder writeable: Yes
Session timeout: 240 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
proto: http
HTTP_HOST: formulation-network.dev
HTTP_CONNECTION: keep-alive
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_REFERER: https://formulation-network.dev/perch/core/settings/diagnostics/
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_COOKIE: p_m=; cmsa=1; _gat=1; _ga=GA1.2.268558264.1485424983; PHPSESSID=i07e90ua7stq04bvrtg5m73mi2
PATH: /usr/bin:/bin:/usr/sbin:/sbin
SERVER_SOFTWARE: Apache/2.4.10 (Unix) PHP/7.0.11
SERVER_NAME: formulation-network.dev
SERVER_ADDR: 127.0.0.1
SERVER_PORT: 80
REMOTE_ADDR: 127.0.0.1
DOCUMENT_ROOT: /Users/danlee/Sites/Work/aceform4-0
REQUEST_SCHEME: http
CONTEXT_DOCUMENT_ROOT: /Users/danlee/Sites/Work/aceform4-0
SERVER_ADMIN: you@example.com
SCRIPT_FILENAME: /Users/danlee/Sites/Work/aceform4-0/perch/core/settings/diagnostics/index.php
REMOTE_PORT: 54172
GATEWAY_INTERFACE: CGI/1.1
SERVER_PROTOCOL: HTTP/1.1
REQUEST_METHOD: GET
QUERY_STRING: extended
REQUEST_URI: /perch/core/settings/diagnostics/?extended
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
PHP_SELF: /perch/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1485856058.282
REQUEST_TIME: 1485856058
It probably isn't this, but as you are not passing an array of categories you could do this:
Just a thought to try
Are you using the
blog
category set?No I wasn't - but am now and it is working. I'm too used to working with collections and I forget the Blog doesn't sing of the same song sheet. Thanks for your help Drew! :)
It does if you tell it - just use a category path any it can be any set you like.
Ok great!