Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello, bit of an odd request but here we go.
On our clients blog, he would like to show all blog posts except from one category.
Eg, list posts from
To see posts from Category B, then you have to go to our-blog/?category=Category+B only.
I was playing around with uBlogsyListPosts.chtml and was wondering if I can add a condition:
var category = Request.QueryString["category"];
if (string.IsNullOrEmpty(category)) { category = everything but Category B }
Would this be possible? Thanks for any help!
For a small-ish site you could do another GetPosts() - NOT the one with many parameters - which will get all the posts.
Then iterate over the allPosts, and remove the nodes that appear in the original posts list.
You will have to do a .ToList() on the
If performance is a problem you will have to use lucene.
Thanks Anthony.
How would I iterate through the posts?
If you take a look at uBlogsyListPosts you'll see a for loop. Use that as a guide.
My solution:
@foreach (DynamicNode n in nodes)
{
allCategories.Clear();
var categories = n.GetProperty("uBlogsyPostCategories").Value.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
allCategories.AddRange(categories);
flag=true;
foreach (var c in allCategories)
if (!string.IsNullOrEmpty(c.Trim()))
if (c=="News"){
flag=false;
}
if (flag){
< something to do >
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Show all posts except from one category
Hello, bit of an odd request but here we go.
On our clients blog, he would like to show all blog posts except from one category.
Eg, list posts from
To see posts from Category B, then you have to go to our-blog/?category=Category+B only.
I was playing around with uBlogsyListPosts.chtml and was wondering if I can add a condition:
Would this be possible? Thanks for any help!
For a small-ish site you could do another GetPosts() - NOT the one with many parameters - which will get all the posts.
Then iterate over the allPosts, and remove the nodes that appear in the original posts list.
You will have to do a .ToList() on the
If performance is a problem you will have to use lucene.
Thanks Anthony.
How would I iterate through the posts?
If you take a look at uBlogsyListPosts you'll see a for loop. Use that as a guide.
My solution:
@foreach (DynamicNode n in nodes)
{
allCategories.Clear();
var categories = n.GetProperty("uBlogsyPostCategories").Value.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
allCategories.AddRange(categories);
flag=true;
foreach (var c in allCategories)
{
if (!string.IsNullOrEmpty(c.Trim()))
{
if (c=="News"){
flag=false;
}
}
}
if (flag){
< something to do >
}
is working on a reply...