Extract lastest posts from blogs

Highlighted
Tourist
19 0 3

Hi,

I'm trying to extract last posts from blogs. I know how to do with single blogs, like this:

{% for article in blogs.mylen-news.articles limit: 5 %}
<li><a href="{{ article.url }}">{{ article.title }}</a></li>
{% endfor %}

But I don't know how I can do it with all my blogs merged.

For example, I've 5 blogs (one for each specific category) and in my homepage I want to extract last 6 news, generally, independant from which blog.
Spefically, if I have category1, category2, category3, category4, category5, and my last 6 articles are published 3 in category1, 1 in category2 and last 2 in category5, I want it to show them arranged in chronological order in my home.

Have only tags in blogs, not categories and have to arrange everthing with this limitation is a bit hard.
My question now is: How I can extract lastest 6 article from all my blogs merged together and order them in chronological order?

Thanks a lot.

0 Likes
Highlighted
Tourist
19 0 3

someone have any clue? I still cannot merge and order an array of all news in my blogs

0 Likes
Tourist
19 0 3

do somebody ever did something like this?

0 Likes
Highlighted
Shopify Expert
9811 92 1574

I guess you could just grab the last 6 from each blog and do a loop to figure out which 6 are the latest. It will be quite the spectacular loop, but it should be doable. To get your starting date (to work back from) would be just comparing each of the newest posts in each blog. Once you have the latest, add that id to a 'skip' list and loop again. Rinse and repeat.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Tourist
19 0 3

Thanks for the answer, as a programmer that was the solution I was adopting but was a bit "patchy", I was getting last 6 posts from each blog (because on the worst scenario, all my 6 recents posts are of the same blog) and I was trying to extract the date to compare it, sort it and arrange it.
It would generate, on the pessimistic case, a matrix of 6x6 compares to get each artiche out.
I'm still trying to figure out how to use array of items with liquid to use a simple sort algorithm on it and just take first 6 items ordered.

Thanks for our answer and time Jason

0 Likes
Highlighted
Shopify Expert
9811 92 1574

 I was getting last 6 posts from each blog (because on the worst scenario, all my 6 recents posts are of the same blog) and I was trying to extract the date to compare it, sort it and arrange it.

That's pretty well my thought.

Of course, if this was me I'd being doing this through the api instead. The loop and sorting process would be far easier.

[edited: I removed my error caused by brain malfunction]

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Tourist
19 0 3

You're right, I'm not skilled using Ajax API on shopify and this will be a great chance to test it.
Have you some hint or example? I searched on documentation but it only refers to products and not blog elements.

What I should include in my code to use ajax api? How can I get specific blogs last posts from ajax api?
How can I impaginate with ajax when I have my 6 lastest news data array ?
Is I can have some hint I can then work on the code by myself and write an extracting algorithm.

I know I'm too greedy but I will seriously appreciate help
Thanks again
 

0 Likes
Highlighted
Shopify Expert
9811 92 1574

 I searched on documentation but it only refers to products and not blog elements.

You're right of course. I was thinking back to my last project when I was pulling in blogs via json, but the feeder was a php app. Still API, but not the AJAX version. This is what happens when you are on the forums and not sleeping.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Tourist
19 0 3

:) thanks for all, I'll try to figure out this problem, at least as a programmer I am good as problem solver too.

Will post here a reply with a solution.

Will be really nice from shopify programmers to include a funcion that grabs all the posts from a single pool, or will be great to have one blog and different categories (with tags).

Have a good nap ;)

 

0 Likes
Highlighted
Shopify Expert
9811 92 1574

Have a good nap ;)

Can't. I'm about to write something to do multi-blog sorting. Have to get it out of my head. I'm sure we'll both end up with a similar solution.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes