We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

List all authors from a specific channel

How Do I?

Youthworks's avatar
Youthworks
47 posts
9 years ago
Youthworks's avatar Youthworks

Hi,

I would like to be able to list all the authors with their member ID (members) from a specific channel. I have not been able to find a solution yet. I did have a look at an old post but couldn’t figure out how to add the member ID.

Hopefully some smart people on this forum could help me.

       
Ingmar's avatar
Ingmar
29,245 posts
9 years ago
Ingmar's avatar Ingmar

I would simply use an SQL query, like this:

{exp:query sql="
SELECT DISTINCT screen_name, member_id 
FROM exp_channel_titles AS t 
INNER JOIN exp_members AS m ON t.author_id = m.member_id
WHERE channel_id = '9'
"}
{/exp:query}

You’ll have to adjust your channel_id, of course.

       
Youthworks's avatar
Youthworks
47 posts
9 years ago
Youthworks's avatar Youthworks

Thanks Ingmar, Works perfectly. How do I sort by screen_name?

       
Ingmar's avatar
Ingmar
29,245 posts
9 years ago
Ingmar's avatar Ingmar

One more line, like so:

{exp:query sql="
SELECT DISTINCT screen_name, member_id 
FROM exp_channel_titles AS t 
INNER JOIN exp_members AS m ON t.author_id = m.member_id
WHERE channel_id = '9'
ORDER BY screen_name ASC
"}
{/exp:query}
       
Youthworks's avatar
Youthworks
47 posts
9 years ago
Youthworks's avatar Youthworks

Thanks a lot Ingmar.

One more thing, using this exp:query Using this exp:query on an entry page (article), the list only display a list of the same author of the article. Is there a way to turn off the dynamic?

       
Ingmar's avatar
Ingmar
29,245 posts
9 years ago
Ingmar's avatar Ingmar

There should be nothing dynamic about this query. Try this:

<ul>
{exp:query sql="
SELECT DISTINCT screen_name AS my_name, member_id AS my_id
FROM exp_channel_titles AS t 
INNER JOIN exp_members AS m ON t.author_id = m.member_id
WHERE channel_id = '9'
ORDER BY screen_name ASC
"}
<li>{my_name} ({my_id})</li>
{/exp:query}
</ul>

Alternatively you could probably put that piece of code in a snippet or subtemplate and just embed it.

       
Youthworks's avatar
Youthworks
47 posts
9 years ago
Youthworks's avatar Youthworks

Yes, that solved it, I guess it just crashed with EE screen_name

Thanks again!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.