Forum Discussion

yeeyang's avatar
yeeyang
Adept
13 years ago
Solved

Most Recent Blog articles with offset

Hello Lithosphere,

 

In Re: http://lithosphere.lithium.com/t5/Lithium-Developers/How-to-retrieve-top-5-recent-posts-from-blog-or-posts-from/td-p/34806

 

So I did the 5 most recent blog article custom component but I wanted to offset that by <anyNumber> so that I can show some and then call in the others in another area or row. Is there a way to offset the REST call?

 

I've tried &offset, &start, and &limit but no go... did lithium use something else?

 

Many thanks!

  • Okay, that's weird. When using on my community the &page parameter works like a pagination parameter as expected. So on your case

    ...?page_size=1&page=1

     ...should show the latest blog post.

    ...?page_size=1&page=2 

     ...should show the second oldest and so on.

5 Replies

  • Hi,

     

    Yes, Lithium is special and therefor uses the &page=2 parameter as the 1-based index of the page to be returned. :) 

  • yeeyang's avatar
    yeeyang
    Adept
    13 years ago

    Thank you Claudius,

     

    While that does work if you have two blogs, it doesn't offset the posts.

     

    For example, if I'm using page-size=3, that gives me the 3 blog posts. What I am would like is to create a custom component which gives me the most recent blog post (page-size=1), then create 3 widgets under it to give me posts 2-4 (2, 3, and 4).

     

    &page gives me posts from another blog (which is very helpful to know but not the solution I was actually looking for.

  • Claudius's avatar
    Claudius
    Boss
    13 years ago

    Okay, that's weird. When using on my community the &page parameter works like a pagination parameter as expected. So on your case

    ...?page_size=1&page=1

     ...should show the latest blog post.

    ...?page_size=1&page=2 

     ...should show the second oldest and so on.

  • yeeyang's avatar
    yeeyang
    Adept
    13 years ago
    Hrm... i find that interesting that doing ?page_size=1&page=1 works but doing ?page_size=3&page1 doesn't. (wanting to show 3 articles with offset of 1)

    I ended up just repeating my code to increment by one in order to get the desired result.

    Thanks!
  • Claudius's avatar
    Claudius
    Boss
    13 years ago

    Glad I could help.
    Just for the record: The page=# parameter is not the offset but the page of the pagination. So page=1 is the first result page and so on. I keep wondering why that's not working right for you...