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

Forums / Developing with Sitefinity / LIMIT Expression on BlogPosts?

LIMIT Expression on BlogPosts?

4 posts, 0 answered
  1. Magnus
    Magnus avatar
    28 posts
    Registered:
    26 May 2009
    23 Sep 2009
    Link to this post
    Hi there.

    I've been searching for some answer about this problem, but couldn't find any. (i might be blind).


    Well. I just wanted to ask if there is any way to use the SQL-commando "LIMIT" in any way for the modules?


    My problem
    I've want to list the latest  3 blogposts using the BlogPost module. That's kinda simple. But i want to start listing from the 2nd post.

    My Goal.
    By using the BlogPost module create a list with the 2nd, 3rd and 4th latest blogpost.
    I want to receive the same result as this MySQL expression....     LIMIT 1,3


    I've tried use the Avanced->Filters textfields but without any luck.


    Kind regards / Magnus


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Sep 2009
    Link to this post
    Hello Magnus,

    "LIMIT" cannot be used in a FilterExpression statement. The way that you can get similar behavior require to create a custom list of items by overriding CreateDataSource method of NewsView control and skipping some of the items that are added to the list. For instance you could have a public property that specify the position of the items that should be hidden.

    I hope this helps.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Magnus
    Magnus avatar
    28 posts
    Registered:
    26 May 2009
    25 Sep 2009
    Link to this post
    Thnaks for the information Ivan.


    It was like i suspected.

    But i still need some help. Is there any information about how to override a control with some good examples? (i'm pretty new in i ASP.net world and havent been learned from scratch. I've learned all by watching examples etc. I know that you dont want to spread all your code. But is there some way to get all the "basecode" for example the BlogPost Module?

    i didnt some searching and just found how to override a BlogPost in the adminsection.


    Is there any code libary or can you help me out with an example?

    kind regards / Magnus
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    25 Sep 2009
    Link to this post
    Hello Magnus,

    BlogPosts is not a module it is a custom control that represents the data created in Blog module. We do not distribute the source code, but you can use Reflector to observe it.

    Below is a sample code that demonstrates how to override blog posts control.

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik.Blogs.WebControls; 
     
    /// <summary> 
    /// Summary description for Class4 
    /// </summary> 
    public class Class4 : BlogPosts 
        public Class4() 
        { 
        } 
     
        public override Type LocalizationAssemblyInfo 
        { 
            get 
            { 
                return typeof(BlogPosts); ; 
            } 
            set 
            { 
                base.LocalizationAssemblyInfo = value; 
            } 
        } 
     
        public override string ItemListTemplatePath 
        { 
            get 
            { 
                return "~/somepath/ItemListTemplatePath.ascx" 
            } 
          
        } 
     
        public override string SingleItemTemplatePath 
        { 
            get 
            { 
                return "~/somepath/SingleItemTemplatePath.ascx"
            } 
             
        } 
     
        protected override System.Collections.IList CreateDataSource(int startIndex, int itemsPerPage) 
        { 
            return base.CreateDataSource(startIndex, itemsPerPage); 
     
            // add logic here 
        } 
     

    You can take a look at our resources

    http://www.sitefinity.com/support.aspx
    http://www.sitefinitywatch.com/

    I hope this helps.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
4 posts, 0 answered