Forum
Exclude section from blog
I'm trying to output a list of posts on a blog section that excludes a specific section which will appear in a members only section.
The site has 5 sections in the blog, all appear in different places and 4 of the 5 will appear in a traditional blog as well.
I'm trying to filter out the section that will appear in the members section as below:
<?php perch_blog_custom(array(
'filter' => 'section',
'match' => 'neq',
'value' => 'prayer',
'count' => 10,
'template' => 'post_in_list.html',
'sort' => 'postDateTime',
'sort-order' => 'DESC',
)); ?>
But it doesn't output anything. This is the debug:
Debug Message
SELECT * FROM perch2_members_sessions WHERE sessionID='bfedaa208a25a89ea05f9c94b7c66fa40088b681' AND sessionHttpFootprint='872bc1e4dce9ec9f34d6db85ac4129327302661b' AND sessionExpires>'2015-07-17 11:54:27' LIMIT 1
User is logged in
SELECT * FROM perch2_pages WHERE pagePath='/blog/index.php' LIMIT 1
SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/blog/index.php' LIMIT 1
SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-006', '000')
Using template: /templates/navigation/item.html
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/blog/index.php' OR regionPage='*' ORDER BY regionPage DESC
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.indexKey='section' AND idx.indexValue != 'prayer')) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID ) as tbl WHERE (postStatus='Published' AND postDateTime<='2015-07-17 11:54:00' ) GROUP BY itemID ORDER BY sortval DESC LIMIT 0, 10
SELECT FOUND_ROWS() AS `count`
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
Using template: /templates/blog/post_in_list.html
Fetching from cache: perch_blog_sections5f4729ea00104e19e850db19093fe150
Am I doing something wrong? Is it not possible to do what I'm trying to do or is there a better way? I don't understand why it's not working because, as far as I can see, it should be.
Thanks.
You need to use the
section
option to filter sections. I doesn't have exclusion yet, but you should be able to include the other 4.Thanks Drew, I just tried that with the following
And I'm getting a MySQL error
Hmm, ok, I thought that should do it, but perhaps you can only include one section at a time.
So does that mean it's not possible to do what I wanted to?
I don't think it's possible with sections. Had you thought about categories? You can query across sections with categories.
Thanks Drew, yeh I've just got to that conclusion. Now down to two sections, one with 4 categories for the general blog and one section for the members area.