1 achillis Sep 28, 2013 14:22
3 achillis Sep 28, 2013 15:33
The problem I am having is that I've set my blog to display one post per page:
$Blog->get_setting( 'posts_per_page' );
so when I use:
while( $Item = & mainlist_get_item() )
{
if( $Item->ID == '#')
{
break;
}
// some code here....
}
then it shows a blank page, follow page links it shows the next post as it should... except I don't want it to show a blank page... ?
4 fplanque Sep 30, 2013 03:13
Then you need to use post types or tags or categories in order to filter out the posts you don't want.
5 achillis Oct 07, 2013 14:01
If I want to filter out by Categories, how will I set the filter?
$MainList->set_filters( array(
// param to use?
// 'categories' => $values;
// 'cat_array' => array( $values );
) );
6 mgsolipa Oct 07, 2013 21:51
Hi @achillis,
Please review this page: http://b2evolution.net/man/advanced-customization/technical-reference/url-params
7 mojolazarus May 20, 2014 13:25
Hi achillis
Did you ever work out what the category filter should look like? I've read several posts on this in the forums but not found a clear answer on filtering out categories. I would like exclude posts from the main list from 2 or 3 categories whilst obviously keeping them in their respective category lists. I thought by adding this filter I could do that. Thanks if you did. I read the link above but still not sure how to proceed.
8 mgsolipa May 20, 2014 22:34
The link above explains, besides of other things, the parameter cat. You may filter the list of post by using that parameter in the URL. For example, is you want to show the posts that belongs only to category 3, then your URL should look like: http://demo3.b2evolution.net/stable/blog1.php?cat=3. In the other hand, if you want to show all the categories but the ID 3, then the URL should be: http://demo3.b2evolution.net/stable/blog1.php?cat=-3 (Note the dash (-) before the number 3).
Finally, if you want to exclude categories 3 and 5, then the URL should look like: http://demo3.b2evolution.net/stable/blog1.php?cat=-3,5.
9 mojolazarus May 20, 2014 23:11
Thanks a lot for that. Yes I would use the minus version (-26, -35 in my case). I'm really interested in seeing if I can get this to be default for my skin. Can I set a filter somehow as achilis suggested?
$MainList->set_filters( array(
// param to use?
// 'categories' => $values;
// 'cat_array' => array( $values );
) );
And put this in my index.main.php file?
I apologise as it's probably obvious how to set the filter but I'm not sure. Would I just add (-26, -35, etc.) into the 'cat array' parentheses as the values?
Thanks
10 mojolazarus May 21, 2014 19:54
From reading what others have tried in different places I got this to exclude 2 categories
if( !in_array( $Item->get('main_cat_ID'), array( 26,29 ) ) )
So, it is close but this excludes the posts from both the main list AND the category list. That is, the category lists for 26 and 29 are blank. I have placed the code immediately after this
while( $Item = & mainlist_get_item() )
. If anyone knows how to get the posts only excluded from the main list that would be great. Thanks.
11 mgsolipa May 21, 2014 22:35
The problem is that both, the main posts list and the category view, are loaded with $disp = "posts"
, which means loading the file skins/_posts.disp.php
or skins/yourskin/post.main.php
(if exists), so you need a way to make a difference in order to show / hide some content, the variable $disp_detail
. You conditional should look like this:
if( !in_array( $Item->get('main_cat_ID'), array( 26, 29 ) ) || $disp_detail == 'posts-cat' || $disp_detail == 'posts-subcat' )
That way, the posts that belongs to categories 26 and 29 will be filtered only in the main posts list.
Having told you all the above, I think that a better solution is to filter the list before to reach the skin.
12 mojolazarus May 21, 2014 23:24
I see, thanks a lot Manuel. I am learning a lot, which is good. I will test that and also think about how to filter the list at source, so to speak. Cheers.
Yes, just replace line 6 with