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.

Custom query help, anyone?

January 30, 2009 4:14pm

Subscribe [1]
  • #1 / Jan 30, 2009 4:14pm

    Ridge

    44 posts

    The Top Entries plugin does almost exactly what I need, except for one thing. I have a custom profile field called {fullname}, which I’d like to use instead of the default {name}. Here’s what does work:

    <h2>Top 10 Article Submitters</h2>
    <p><ul><br />
    {exp:top_authors weblog="weblog" limit="10"}<br />
    <li>{name} - {count}</li><br />
    {/exp:top_authors}<br />
    </ul>

    Here’s what doesn’t, but what I need:

    <h2>Top 10 Article Submitters</h2>
    <p><ul><br />
    {exp:top_authors weblog="weblog" limit="10"}<br />
    <li>{fullname} - {count}</li><br />
    {/exp:top_authors}<br />
    </ul>

    I’m assuming I’ll need some kind of custom query to mimic this plugin’s output, but I don’t know where to start. Can a kindly soul help me out?

  • #2 / Jan 30, 2009 7:16pm

    Ridge

    44 posts

    I almost have it. I used this custom query:

    <h2>Top 10 Article Submitters</h2>
    <p><ul><br />
    {exp:query sql="SELECT m.*, m_field_id_3 as full_name, total_entries<br />
    FROM exp_members m, exp_member_data d WHERE m.member_id = d.member_id ORDER BY total_entries DESC LIMIT 10"}<br />
        <li>{full_name} - {total_entries}</li><br />
    {/exp:query}<br />
    </ul>

    Which generates a list of top submitters across the site in every weblog. My one remaining question is, how can I limit this query to only one weblog?

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

ExpressionEngine News!

#eecms, #events, #releases