Thanks for quick reply.Could you please tell me how can i get categories. else {
// get tag, category, or author from query string var tag = Request.QueryString["tag"]; var category = Request.QueryString["category"]; var author = Request.QueryString["author"]; var searchTerm = Request.QueryString["search"]; var commenter = Request.QueryString["commenter"]; int page = int.TryParse(Request.QueryString["page"], out page) ? page : 1;
I have done this.I have created new cshtml file and embeded my own code and its working fine.Now i have another issue.Could you please tell me how to get most recent post.
Group by Category
Hi,
I am working on UBlogsy from last 3 days.I am facing one issue.Is it possible to group posts according to category on home page.
For example following are the post:
Post category
test1 category1
test2 category1
test3 category2
Now i wanna show :
Categories: Category1
test1
test2
Categories: Category2
test3
So can we group post?
Thanks
Anuj
You can do anything...
Take a look at the uBlogsyListCategories.cshtml
This will show you how to get all the categories.
In uBlogsyListPosts.cshtml (or a copy of that file), once you have the categories you can get posts by category
foreach (var category in categories){
var posts = PostService.Instance.GetPosts(Model.Id, string.Empty, category, string.Empty , string.Empty , string.Empty , 0, ITEMS_PER_PAGE);
// insert your markup here
}
Thanks for quick reply.Could you please tell me how can i get categories.
else
{
// get tag, category, or author from query string
var tag = Request.QueryString["tag"];
var category = Request.QueryString["category"];
var author = Request.QueryString["author"];
var searchTerm = Request.QueryString["search"];
var commenter = Request.QueryString["commenter"];
int page = int.TryParse(Request.QueryString["page"], out page) ? page : 1;
}
Its showing empty category.
The code you're looking at is for getting the category from the query string.
Don't you just want to list all the categories and posts with that category?
Take a look at the uBlogsyListCategories.cshtml
There is a for loop which lists categories.
For each of those categories, instead of rendering the category, you want to use this:
foreach (var category in categories){
var posts = PostService.Instance.GetPosts(Model.Id, string.Empty, category, string.Empty , string.Empty , string.Empty , 0, ITEMS_PER_PAGE);
// insert your markup here
}
But you want all of this either in uBlogsyListPosts, or in another cshtml file. eg uBlogsyListPostsByCategory
Hi,
Sorry for late reply, i want to show posts group by category in uBlogsyShowPost.cshtml.
Thanks
Hi Anthony,
I have done this.I have created new cshtml file and embeded my own code and its working fine.Now i have another issue.Could you please tell me how to get most recent post.
Thanks.
There's a few ways that comes to mind
Here's the first
var posts = PostService.Instance.GetPosts(Model.Id, string.Empty, string.Empty, string.Empty , string.Empty , string.Empty , 0, 1);
var post = posts.FirstOrDefault();
is working on a reply...