Forum

Thread tagged as: Configuration, Blog

Blog post types

Hi there,

Just updated an old blog to P3 and imported into the new site I'm making for it. There are three post types - which show up - and when I go to add to a post-type it's not actually setting the post correctly as when I try filter posts by category or section they don't appear under anything, they will only appear under 'posts'.

The imported data filters down as I would expect, with the correctly set post type. I can't workout what's causing it not to set the post type. I can see in the debug that the correct post type template is being used. Nothing else in the debug points towards any visible errors.

Mathew Doidge

Mathew Doidge 2 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Could you give some steps to reproduce the issue? I don't quite follow your description.

Apologies, I'll try be clearer.

So I have a Perch 3 Runway site locally I'm developing and I've imported the blog from the old site which was running the previous version of Perch. The posts have all imported without a problem.

I have sections and categories as well as post types. Now at the moment the problem is, if I try to add a new post to one of the three post types, it doesn't appear to be adding itself to that particular post-type. For instance, if I add a post to 'Workout Diary' and I go to the workout page where I have the function pulling those posts out:

<?php 
    perch_blog_custom(array(
        'template' => 'wod_listing.html',
        'count' => 6,
        'section' => 'workout-diary',
        'sort' => 'postDateTime',
        'sort-order' => 'DESC'
    ));
?>

I don't see anything other than my imported posts. And additionally when I try sorting on the posts page in the admin, the post isn't appearing under sort-by sections, it seems to only be there if I click on 'blog' rather than by section or category.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is "workout diary" a section or a post type? You seem to be conflating the two.

It's actually both - I set the original site up when I was quite new to Perch and I'm not sure why I set it up like this, but it's actually a section and a post type.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, so is the issue with sections, or with the post type?

I've just adjusted the code above and I think the section is the problem. If I change 'section' => 'workout-diary', to 'section' => 'news' the post still isn't appearing. So it's not going into any section. Only if I remove the section argument do I see my test post.

Drew, and I correct in that I should be getting a dropdown on the post itself to select a section, as it has been in older versions of the blog addon?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you should be able to choose the section.

Oddly, the sections dropdown isn't appearing on any of the post types

Drew McLellan

Drew McLellan 2638 points
Perch Support

In the meta tab?

Whoops... moved here from incorrect thread.

Sorry Drew, I missed that initially.

I've done some testing, posting to both sections - news and workout diary.

My workout diary section gets posts absolutely fine but posting anything to my news section doesn't appear to be working. The news section itself has two categories within it, which is the only difference between news and workout diary. The categories are articles and athlete spotlight.

I pull these posts directly onto the news page via:

<?php
    perch_blog_custom(array(
            'template' => 'news_listing.html',
            'count' => 6,
            'section' => 'news',
            'sort' => 'postDateTime',
            'category' => array('news/articles/', 'news/athlete-spotlight/'),
            'sort-order' => 'DESC',
        ));
?>

Even if I remove the category part, the post isn't appearing. I've triple checked and these test posts I am trying are definitely set to the news section.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does debug output?

Time    Δ   Debug Message - Perch Runway 3.0
0.0313  0   [1] SELECT u.*, r.* FROM perch3_users u, perch3_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='31d04ef0e4482f7c5ec9a467e21908ee' LIMIT 1
0.0317  0.0003  UPDATE perch3_users SET userHash='a42676fa413e73d0638ee480bbe0ede7' WHERE userID='1'
0.0318  0.0002  [34] SELECT p.privKey FROM perch3_user_privileges p
0.0369  0.0051  [28] SELECT settingID, settingValue, userID FROM perch3_settings WHERE userID=1 OR userID=0 ORDER BY userID ASC
0.0541  0.0171  [9] SELECT itemValue FROM perch3_menu_items WHERE itemType='app'
0.0601  0.006   [0] SELECT COUNT(*) FROM perch3_blog_comments WHERE commentStatus='PENDING'
0.0644  0.0043  [1] SELECT * FROM perch3_blog_authors WHERE authorEmail='hello@visualdecree.co.uk' LIMIT 1
0.0666  0.0022  [1] SELECT * FROM perch3_blog_posts WHERE postID=502
0.0692  0.0026  [2] SELECT * FROM perch3_blog_sections ORDER BY sectionTitle ASC
0.0703  0.0011  [1] SELECT * FROM perch3_blogs ORDER BY blogTitle ASC
0.0716  0.0014  [1] SELECT * FROM perch3_blogs WHERE blogID=1 LIMIT 1
0.076   0.0043  [2] SELECT * FROM perch3_blog_sections WHERE blogID='1' ORDER BY sectionTitle ASC
0.0827  0.0067  Using template: /addons/apps/perch_blog/templates/blog/post_meta.html
0.0959  0.0132  UPDATE perch3_blog_posts SET postTags='', postAllowComments='1', postTemplate='post.html', authorID='1', sectionID='2', postDynamicFields='{\"image\":null,\"_blocks\":[{\"postDescHTML\":{\"_flang\":\"textile\",\"raw\":\"sad asdsadaa aa asd\",\"processed\":\"<p>sad asdsadaa aa asd<\\/p>\"},\"_block_type\":\"textblock\",\"_block_id\":\"oo1kfl\",\"_block_index\":\"0\"}],\"theme\":\"dark\",\"excerpt\":{\"_flang\":\"markdown\",\"raw\":\"asda sadsada dadadasdasdasd\",\"processed\":\"<p>asda sadsada dadadasdasdasd<\\/p>\"},\"categories\":[\"1\"],\"og_title\":\"Matt is great\",\"og_description\":{\"_flang\":\"plain\",\"raw\":\"asda sadsada dadadasdasdasd\",\"processed\":\"asda sadsada dadadasdasdasd\"},\"og_image\":null,\"og_type\":null}' WHERE postID='502'
0.0962  0.0003  No ids to log.
0.0962  0   DELETE FROM perch3_blog_posts_to_tags WHERE postID='502'
0.0963  0.0001  DELETE FROM perch3_blog_index WHERE itemKey='postID' AND itemID='502'
0.0993  0.003   INSERT INTO perch3_blog_index (itemKey, itemID, indexKey, indexValue) VALUES ('postID',502,'image',''),('postID',502,'theme','dark'),('postID',502,'excerpt','<p>asda sadsada dadadasdasdasd</p>'),('postID',502,'excerpt__flang','markdown'),('postID',502,'excerpt_raw','asda sadsada dadadasdasdasd'),('postID',502,'excerpt_processed','<p>asda sadsada dadadasdasdasd</p>'),('postID',502,'categories_0','1'),('postID',502,'og_title','Matt is great'),('postID',502,'og_description','asda sadsada dadadasdasdasd'),('postID',502,'og_image',''),('postID',502,'og_type',''),('postID',502,'postID','502'),('postID',502,'blogID','1'),('postID',502,'postTitle','Matt is great'),('postID',502,'postSlug','2017-04-07-matt-is-great'),('postID',502,'postDateTime','2017-04-07 14:35:00'),('postID',502,'postDescRaw',''),('postID',502,'postDescHTML',''),('postID',502,'postTags',''),('postID',502,'postStatus','Draft'),('postID',502,'authorID','1'),('postID',502,'sectionID','2'),('postID',502,'postCommentCount','0'),('postID',502,'postImportID',''),('postID',502,'postLegacyURL',''),('postID',502,'postAllowComments','1'),('postID',502,'postTemplate','post.html'),('postID',502,'postMetaTemplate','post_meta.html'),('postID',502,'itemID',''),('postID',502,'itemRowID',''),('postID',502,'postURL','2017-04-07-matt-is-great'),('postID',502,'_id',502)
0.1005  0.0012  [1] OPTIMIZE TABLE perch3_blog_index
0.1375  0.037   [2] SELECT COUNT(*) AS qty, c.catID FROM perch3_blog_index i, perch3_categories c, perch3_blog_posts p WHERE i.indexValue=c.catPath AND i.indexKey='_category' AND i.itemKey='postID' AND i.itemID=p.postID AND p.postStatus='Published' AND p.postDateTime<='2017-04-07 14:36:00' GROUP BY i.indexValue, c.catID
0.1466  0.0091  DELETE FROM perch3_category_counts WHERE countType='blog.post'
0.1481  0.0015  [1] SELECT * FROM perch3_categories WHERE catID=1 LIMIT 1
0.1491  0.001   DELETE FROM perch3_category_counts WHERE catID=1 AND countType='blog.post'
0.1492  0.0001  INSERT INTO perch3_category_counts(countType,countValue,catID) VALUES('blog.post',26,'1')
0.1496  0.0004  [1] SELECT * FROM perch3_categories WHERE catID=2 LIMIT 1
0.1497  0.0001  DELETE FROM perch3_category_counts WHERE catID=2 AND countType='blog.post'
0.1498  0.0001  INSERT INTO perch3_category_counts(countType,countValue,catID) VALUES('blog.post',17,'2')
0.1502  0.0004  [2] SELECT authorID, COUNT(*) AS qty FROM perch3_blog_posts WHERE postStatus='Published' AND postDateTime<='2017-04-07 14:36:00' GROUP BY authorID
0.1512  0.0011  UPDATE perch3_blog_authors SET authorPostCount=0
0.1514  0.0001  UPDATE perch3_blog_authors SET authorPostCount='4' WHERE authorID=1 LIMIT 1
0.1515  0.0001  UPDATE perch3_blog_authors SET authorPostCount='445' WHERE authorID=2 LIMIT 1
0.1515  0.0001  [2] SELECT c.sectionID, COUNT(p.postID) AS qty FROM perch3_blog_sections c, perch3_blog_posts p WHERE c.sectionID=p.sectionID AND p.postStatus='Published' AND p.postDateTime<='2017-04-07 14:36:00' GROUP BY c.sectionID ORDER BY c.sectionTitle ASC
0.1531  0.0015  UPDATE perch3_blog_sections SET sectionPostCount=0
0.1532  0.0001  UPDATE perch3_blog_sections SET sectionPostCount='45' WHERE sectionID='2' LIMIT 1
0.1534  0.0002  UPDATE perch3_blog_sections SET sectionPostCount='404' WHERE sectionID='4' LIMIT 1
0.1575  0.0041  [1] SELECT * FROM perch3_menu_items WHERE itemActive=1 AND itemType='menu' AND parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1
0.1578  0.0003  [4] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC
0.1587  0.0009  [1] SELECT itemTitle FROM perch3_menu_items WHERE itemType='app' AND itemValue='perch_blog' LIMIT 1
0.1589  0.0002  [1] SELECT * FROM perch3_menu_items WHERE itemActive=1 AND itemType='menu' AND parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10
0.1591  0.0001  [2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC
0.16    0.0009  File: /addons/apps/perch_blog/modes/edit.meta.post.php
0.1633  0.0033  [3] SELECT * FROM perch3_blog_authors ORDER BY authorFamilyName, authorGivenName ASC
0.1657  0.0024  Queries: 52
0.1657  0   Memory: 3.6505

I just noticed a method for getting it to show, which seems like it could perhaps be a bug, or maybe a problem with my setup.

If I add a new post, assigned to articles category within the news section, set to published - it will not show up unless I save, go to meta and hit save under meta, then go back to the post screen and hit save one more time, then it appears on the front-end.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you make any changes at that point, or just resave?

Just re-saved

Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm, that sounds like something I need to look into.

Ok, thanks Drew!

Hi Drew,

Just a small update to this. I've noticed some other strange behavior on the blog — linked to this. If I go into make any edits to posts within one of my categories, save again, the post then vanishes from the listing but this time getting it to re-reappear is a lot harder than just a few saves.

And lastly, this could be separate but I noticed new posts are not picking up the image, despite being uploaded to a blog content field called image - they are instead being mapped to an id of perch_image which is no where in my templates. I don't if the image problem warrants a new thread?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Every ID gets prefixed internally and in the templates, but they're duplicates. It doesn't sound like the same problem at all, so you should post a new thread so I can keep track.