1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Retrieve post based on author name

Retrieve post based on author name

6 posts, 1 answered
  1. Sharon
    Sharon avatar
    17 posts
    Registered:
    06 Feb 2009
    20 Jul 2009
    Link to this post
    Can someone help me with a sample code on how to retrieve blog posts based on author name.

    Thanks in advance,
    Sharon Johnson
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    20 Jul 2009
    Link to this post
    Hi Sharon,

    The API does not support retrieving blog posts by author. You can return all post from a blog that has Author.

       var manager = new BlogManager(); 
            IList listofBlogs = manager.GetBlogs(); 
            foreach (IBlog bl in listofBlogs) 
            { 
                if (bl.Author.Equals("Ivan Dimitrov")) 
                { 
                    IList cntList = manager.GetPosts(string.Empty, new Guid[] {bl.ID}); 
                    foreach (IContent o in cntList) 
                    { 
                       // do something 
                    } 
                } 
            } 


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Sharon
    Sharon avatar
    17 posts
    Registered:
    06 Feb 2009
    21 Jul 2009
    Link to this post
    Thanks a lot Ivan for your immediate reply..

    I'm able to retrieve posts based on tags and categories, I'm not able to do the same with author name. Is there any inbuilt feature to achieve this or do I have to do any work around.

    Please help me on this.

    Thanks,
    Sharon Johnson.
  4. Sharon
    Sharon avatar
    17 posts
    Registered:
    06 Feb 2009
    21 Jul 2009
    Link to this post
    I dragged and dropped bloggers control in my page, but when I click on a blogger, it lists me all the available posts but I want it to display only the post of the particular blogger that was clicked. I do not know how to achieve this, could someone please let me know on the settings or the steps I have to do to achieve this.

    Thanks,
    Sharon Johnson.
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jul 2009
    Link to this post
    Hi Sharon,

    "The API does not support retrieving blog posts by author." If you add the code in debugger you will see that there is no author for the content item. The Author appears only for the blog. The Content items are associated with the blog ID( parent ID)

    The last issue you have:

    You should create Blog page where all posts will be visible. Then create a new page - say User's Blog. There drop Blog Posts control and filter the users by blog for the control designer ( step one). By doing so on this page you will have the posts created only from your "User". The same approach is used at http://blogs.sitefinity.com/

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
    Answered
  6. Sharon
    Sharon avatar
    17 posts
    Registered:
    06 Feb 2009
    21 Jul 2009
    Link to this post
    Hi Ivan,
    Thank you so much for your immediate reply, and this saved the day for me. Your reply was the one I was actually looking for.

    Thank you once again.

    Sharon Johnson.
Register for webinar
6 posts, 1 answered