ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

one entry per weblog

December 14, 2009 12:18pm

Subscribe [1]
  • #1 / Dec 14, 2009 12:18pm

    Peter Hampus

    30 posts

    I want to pull data from 5 different weblogs and display them ordered by date.
    But I want only one entry per weblog to show up, even if one weblog has the 5 most resent entries.
    How can that be done?

    Thanks!

  • #2 / Feb 22, 2010 5:17am

    Peter Hampus

    30 posts

    I’ll try to explain again what I try to do:

    I display six different blogs like this:
    http://chef.se/blogg

    But I want the most recent blog to appear at the top, and the others descending. And only one entry per blog.

    All bloggers have their own weblog.

    How can that be done?

    Now I just put six different

    {exp:weblog:entries}

    tags and set limit to 1.

  • #3 / Feb 22, 2010 9:48am

    ender

    1644 posts

    you’ll need to use a custom query for this.

  • #4 / Feb 22, 2010 10:38am

    Peter Hampus

    30 posts

    Hmm, haven’t done many custom queries. Can anyone point me in the right direction?
    Thanks!

  • #5 / Feb 22, 2010 11:22am

    ender

    1644 posts

    http://dev.mysql.com/doc/refman/5.0/en/select.html 😉

    SELECT
        w.weblog_id,
        w.blog_name,
        t.entry_id,
        t.title,
        t.url_title,
        t.entry_date,
        d.field_id_XX AS my_custom_field
    FROM
        exp_weblogs AS w NATURAL JOIN
        exp_weblog_titles AS t NATURAL JOIN
        exp_weblog_data AS d JOIN
        (
            SELECT 
                t.entry_id,
                MAX(t.entry_date)
             FROM
                exp_weblogs AS w NATURAL JOIN
                exp_weblog_titles AS t
            WHERE
                w.blog_name IN ('blog','portfolio','services')
            GROUP BY
                w.weblog_id
        ) AS p ON t.entry_id=p.entry_id
    ORDER BY
        t.entry_date DESC;

    give this a try… fill in your blog names where I’ve got ‘blog’,‘portfolio’,‘services’ and replace d.field_id_XX AS my_custom_field with appropriate values for your own custom fields.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases