Forum
Problem showing Categories with multiple blogs and default post template issues
Hi,
This is following on from my recent post here about problems filtering categories by section (https://forum.grabaperch.com/forum/04-10-2017-filter-blog-categories-by-section) but I think a new thread is more appropriate.
I have two blogs set up on a multilingual Runway project. The Blogs are called Blog (with slug, blog) and Noticias (with slug, noticias). The former uses a default master template called Post (post.html) and the latter a default master template called Post es (post-es.html). Blog uses a category set called Blog, and Noticias uses a category set called Blog ES. The two master templates for each blog allow the user to select categories from the appropriate set.
Blog is located at /en/blog and Noticias at /es/noticias.
I need to be able to show the categories in use by each blog. I'm using the following to do this, where $blog is a variable that outputs the correct blog slug (i.e. either slug or noticias).
<?php
perch_blog_categories(array(
'blog' => $blog,
'template' => 'category_link.html',
'cache' => false,
));
?>
I'm having issues when it comes to the Noticias blog and here's what I've noticed.
I can create a post in Noticias and assign categories as I would expect to (from the Blog ES category set). The post will display correctly and the perch_blog_categories() function above will output the categories used correctly. But if I then switch to the Meta and Social tab, make any edits and save, and then switch back to the post editing tab, I can see from Debug that that post template has changed from post-es to post. This of course means that the Categories available to this post are no longer correct.
At this point I can see no way of changing the post template back to the correct one. (Should I be able to switch the post template via the admin?)
If I then recreate the post, and don't make any edits to the Meta and Social tab, then I have another issue in that I'm unable to see this post in my category archive listing. On this page I'm pretty much using the default archive.php file which is working as I'd expect for the English blog (Blog) but not for the Noticias blog.
This is what I have to show the Category listing:
if (perch_get('cat')) {
echo '<h1>Category archive: '.perch_blog_category(perch_get('cat'), true).'</h1>';
perch_blog_custom(array(
'category' => 'perch_get('cat')',
'template' => $template,
'count' => 10,
'sort' => $sort_by,
'sort-order' => $sort_order,
'blog' => $blog
));
$posts_displayed = true;
}
Specifically perch_blog_category(perch_get('cat'), true) doesn't return anything and the perch_blog_custom doesn't return anything although everything works correctly on the English blog (the one called Blog).
I hope I've been able to explain this adequately. If anything isn't clear, please let me know.
Here is my Diagnostics:
Perch Runway: 3.0.1
Production mode: Production (100)
Installed apps: content (3.0.1), assets (3.0.1), categories (3.0.1), perch_blog (5.5.1), perch_forms (1.9), perch_mailchimp (3.1)
DB driver: PDO
DB tables: perch2_backup_plans (0), perch2_backup_resources (0), perch2_backup_runs (0), perch2_blog_authors (5), perch2_blog_comments (966), perch2_blog_index (5365), perch2_blog_posts (83), perch2_blog_posts_to_tags (66), perch2_blog_sections (1), perch2_blog_tags (35), perch2_blogs (2), perch2_categories (7), perch2_category_counts (7), perch2_category_sets (2), perch2_collection_index (0), perch2_collection_items (0), perch2_collection_revisions (0), perch2_collections (0), perch2_content_index (29309), perch2_content_items (2943), perch2_content_locks (0), perch2_content_regions (249), perch2_forms (6), perch2_forms_responses (2174), perch2_mailchimp_campaigns (48), perch2_mailchimp_history (2), perch2_mailchimp_imports (2), perch2_mailchimp_lists (5), perch2_mailchimp_log (1445), perch2_mailchimp_stats (1), perch2_mailchimp_subscribers (424), perch2_mailchimp_subscriptions (427), perch2_mailchimp_webhooks (7), perch2_members (0), perch2_members_forms (1), perch2_members_member_tags (0), perch2_members_sessions (0), perch2_members_tags (1), perch2_menu_items (11), perch2_navigation (4), perch2_navigation_pages (28), perch2_page_routes (21), perch2_page_templates (26), perch2_pages (65), perch2_resource_log (17278), perch2_resource_tags (1), perch2_resources (3964), perch2_resources_to_tags (2), perch2_settings (48), perch2_user_passwords (2), perch2_user_privileges (46), perch2_user_role_privileges (42), perch2_user_roles (3), perch2_users (6)
Users: 6
App runtimes:
<?php
$apps_list = [
'perch_forms',
'perch_mailchimp',
'perch_blog'
];
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Scheduled tasks for perch_mailchimp: import_data (1 mins)
Editor plug-ins:
H1: 1e33646f57cfd7ebf1597c69467aeb67
L1: 73ab83eeab60b2f3ae80bdecde38a945
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
headerColour: #ffffff
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.5.4: done
headerScheme: light
dashboard: 0
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
update_2.6.3: done
update_2.6.6: done
perch_mailchimp_secret: 6a2d75da8bcb1edd1a23f201d82fc9e5
perch_mailchimp_update: 2.0
perch_mailchimp_api_key: a7f6d0cac1ac9ac3fa02796ae3d093bf-us9
perch_mailchimp_list_id: f5a1edc970
perch_mailchimp_campaign_url: /mailchimp/campaign.php?s={campaignSlug}
update_2.7.2: done
update_2.7.6: done
update_2.7.7: done
update_2.7.8: done
update_2.7.10: done
update_2.8.2: done
update_2.8.6: done
update_2.8.7: done
update_2.8.8: done
latest_version:
perch_blog_update: 5.0.1
perch_blog_post_url: /{blogSlug}/{postSlug}
perch_blog_slug_format: {postTitle}
perch_blog_akismet_key: 329934970c04
perch_blog_comment_notify: 1
perch_blog_max_spam_days: 0
update_2.8.11: done
update_2.8.13: done
update_2.8.17: done
update_2.8.26: done
update_2.8.31: done
perch_blog_site_name: XXXXXXXX
update_3.0.1: done
update_runway_3.0.1: done
on_sale_version: 3.0.1
siteOffline: 0
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_DB_USERNAME: perch
PERCH_DB_SERVER: localhost
PERCH_DB_DATABASE: perch_XXXXXXXX_en
PERCH_SITEPATH: /D/sites/XXXXXXXX/en/httpdocs
PERCH_DEBUG: 1
PERCH_DB_PREFIX: perch2_
PERCH_TZ: Europe/Madrid
PERCH_EMAIL_FROM: info@XXXXXXXX
PERCH_EMAIL_FROM_NAME: XXXXXXXX
PERCH_LOGINPATH: /perch
PERCH_PATH: D:\sites\XXXXXXXX\en\httpdocs\perch
PERCH_CORE: D:\sites\XXXXXXXX\en\httpdocs\perch\core
PERCH_RESFILEPATH: D:\sites\XXXXXXXX\en\httpdocs\perch\resources
PERCH_RESPATH: /perch/resources
PERCH_HTML5: 1
PERCH_CLEAN_RESOURCES:
PERCH_YOUTUBE_API_KEY: AIzaSyBYMt2CbubARwkw2247ddjIP76174ux9Lk
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_ASSET_VERSION: 7ca631ef9a54e99e413a
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: D:\sites\XXXXXXXX\en\httpdocs\perch\templates
PERCH_TEMPLATE_FILTERS:
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_PRODUCTION_MODE: 100
PERCH_XHTML_MARKUP:
PERCH_RWD: 1
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_DEFAULT_BUCKET: default
PERCH_TRANSLATION_ASSIST:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_PRIV_ASSIST:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_APPS_EDITOR_PLUGIN: markitup
PERCH_APPS_EDITOR_MARKUP_LANGUAGE: markdown
Hosting settings
PHP: 5.6.21
Zend: 2.6.0
OS: WINNT
SAPI: apache2handler
Safe mode: not detected
MySQL client: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $
MySQL server: 5.6.30
Free disk space: 1.65 GB
Extensions: Core, bcmath, calendar, ctype, date, ereg, filter, ftp, hash, iconv, json, mcrypt, SPL, odbc, pcre, Reflection, session, standard, mysqlnd, tokenizer, zip, zlib, libxml, dom, PDO, bz2, SimpleXML, wddx, xml, xmlreader, xmlwriter, apache2handler, openssl, curl, fileinfo, gd, gettext, gmp, imap, mbstring, exif, mysql, mysqli, Phar, pdo_mysql, pdo_sqlite, soap, sockets, sqlite3, tidy, xmlrpc, xsl, com_dotnet, mhash, ionCube Loader
GD: Yes
ImageMagick: No
PHP max upload size: 128M
PHP max form post size: 128M
PHP memory limit: 128M
Total max uploadable file size: 128M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: No
TMP: C:/Program Files (x86)/Ampps/tmp
HTTP_HOST: dev.en.XXXXXXXX
HTTP_CONNECTION: keep-alive
HTTP_PRAGMA: no-cache
HTTP_CACHE_CONTROL: no-cache
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_REFERER: https://dev.en.XXXXXXXX/perch/core/settings/diagnostics/
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_ACCEPT_LANGUAGE: en-GB,en-US;q=0.8,en;q=0.6,es;q=0.4
HTTP_COOKIE: _ga=GA1.2.1829650610.1491831047; _ga=GA1.3.1829650610.1491831047; PHPSESSID=lp1aigek78202dgpojnlrk0ai2; cmsa=1
PATH: C:\Program Files\ImageMagick-6.8.9-Q16;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Adobe\AGL;C:\Program Files\nodejs\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\PuTTY\;C:\Users\SKelly\AppData\Roaming\npm;C:\Ruby193\bin
SystemRoot: C:\Windows
COMSPEC: C:\Windows\system32\cmd.exe
PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
WINDIR: C:\Windows
SERVER_SOFTWARE: Apache/2.4.20 (Win32) OpenSSL/1.0.2g PHP/5.6.21 mod_wsgi/4.4.21 Python/3.5.1
SERVER_NAME: dev.en.XXXXXXXX
SERVER_ADDR: 127.0.0.1
SERVER_PORT: 80
REMOTE_ADDR: 127.0.0.1
DOCUMENT_ROOT: D:/sites/XXXXXXXX/en/httpdocs
REQUEST_SCHEME: http
CONTEXT_DOCUMENT_ROOT: D:/sites/XXXXXXXX/en/httpdocs
SERVER_ADMIN: admin@localhost
SCRIPT_FILENAME: D:/sites/XXXXXXXX/en/httpdocs/perch/core/settings/diagnostics/index.php
REMOTE_PORT: 53483
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: 1492002089.315
REQUEST_TIME: 1492002089
Thanks is advance for any help or suggestions.
Have you tried turning on debug on the page that contains
perch_blog_category(perch_get('cat'), true)
to see what query is being sent to the database?I don't know this for sure, but I wonder if the
Blog ES
set name is causing issues - maybe the category slug isn't forming correctly or something daft. That's the only difference between your blog and blob es sets.Hi Duncan,
Thanks for your reply.
I've had a look at Debug on an archive page that is displaying as expected and an archive that isn't working as expected. The EN page mentions the catPath as follows:
And on the ES page I'm getting:
but of course I'd expect the catPath to be blog-es/gente.
I'll try renaming the category sets and see if that make any difference. Thanks again for your input — much appreciated.
No problem.
It might just be that the link to that page isn't being formed properly - is your category_link.html template hard coding blog/ at the start of the path or something?
But without a doubt, debug always helps - in fact if I'm developing anything, I leave debug turned on all the time, just to see exactly what's going on...
Yes, the links from the category_link.html are all as I'd expect them to be.
So I changed the category set name from Blog ES to Noticias (with a slug of noticias) and am still having issues. Output from the following will now correctly show all categories in use for the EN blog but shows categories from both blogs when variable $blog returns the slug of the ES blog:
And the issue of the post template being change when a save is made in the Meta and Social Tab still persists.
The category archive (on the ES blog) still doesn't output as expected/hoped. This is Debug output on a category archive page for a category called Gente that I'd expect to be in the Noticias set.
Any suggestions very gladly received!
I have a feeling that the blog app might be restricted to using the
blog
category set - it's hard coded to do so.You/I might need to do some forum searches to confirm that.
Good call, Duncan, thanks. I've been able to make some progress ;)
I can get the archive page to show the listings as I'd expect (thanks to this post https://forum.grabaperch.com/forum/12-16-2015-does-a-category-set-have-still-have-to-be-called-blog-to-work-with-the-blog-app), which leaves me with two remaining issues: edits to the Meta and Social tab changing the post template in such as way that I can't change it back, and the perch_blog_categories function not outputting just the categories of the ES blog when I expect it to.
Progress though... thanks for your help.
OK, I have it down to just one issue now, I think. And that's the issue of the post template being switched when I make an edit/save in the Meta and Social tab, and this has me stumped. If I could switch it back manually then that's something I could live with right now but I can't see any option for that. Unless I'm missing something?
This last issue seems to be because my alternative post template for the ES blog was in /blog and not /blog/posts so I guess that was messing things up. Pleased to say this all appears to be resolved now ;)