Help - Search - Members - Calendar
Full Version: List of Authors
Movable Type Community Forum > Additional Resources > Tips and Tricks
The Dead One
I've created a collobration web site using Movable Type between a few friends but I'd like to have a a list of the authors in the corner of the main page (and links to either email or webpage or stats).

Is it possible to do this in some dynamic fashion rather then by hand?

I've looked through the Moveable Type documentation and you can do this for Categories and Entires but not for Authors.
kadyellebee
There isn't currently any way I've found to dynamically create this.  I create all the lists on theredkitchen by hand as I add authors.  

Kristine
bmk
You could do it using the mysql backend with:

$listauth = "SELECT author_id, author_name, author_nickname, author_email, author_url FROM mt_author";

Here's sample code (but you can make it output however you wish... you just change the echo line.)  You need to configure the database connection to let the code know where the data is.  Fill in name_of_database, domain, user, and pass.
CODE
<?php

$database = "name_of_database";
$db = mysql_connect("www.domain.com", "user", "pass");
mysql_select_db("$database",$db);


$listauth = "SELECT author_id, author_name, author_nickname, author_email, author_url FROM mt_author";

$result = mysql_query($listauth);




while ($row = mysql_fetch_array($result)) {

echo "<p>", "Author ", ($row['author_id']), ": ", ($row['author_name']), " (", ($row['author_nickname']), ") <a href=\"mailto:", ($row['author_email']), "\">email</a> <a href=\"", ($row['author_url']), "\">homepage</a></p><br />\n";

}

mysql_free_result($result);

?>
 You're probably going to want to work some sort of spam protect in there if you're going to display the emails.

Hope this helps!
Brenna
kadyellebee
Oh my goodness, you rock! smile.gif  Now I'm gonna go back and look for a thread that might tell me how to do this so it just displays the authors attached to one blog instead of all of the ones in my entire database... I'll post back if I find it! smile.gif

Kristine
kadyellebee
Hmmm, I believe that somehow I have to connect author_id with permission_author_id so I can output permission_blog_id.

I want to display only the authors with permssion to post to blog_id=3

Maybe something like this:
CODE
//not true code - not sure how to do this yet//

$authid = "SELECT author_id FROM mt_author";
$permid = "SELECT permission_author_id FROM mt_permission";
$permblog = "SELECT permission_blog_id FROM mt_permission";


where $authid=$permid if $permblog = "3"
then $listauth=SELECT author_name, author_nickname, author_email, author_url FROM mt_author";


Hmmm, I think I'll do some searching on Google to see if I can figure out how to do this smile.gif  I may be totally barking up the wrong tree - when Brenna comes back, she can straighten me out smile.gif

K
bmk
You could change the query to also check the mt_permission table and only return authors that have permission_blog_id set to the blog you specify (8 in this example)

CODE
$listauth = "SELECT a.author_id, a.author_name, a.author_nickname, a.author_email, a.author_url FROM mt_author a, mt_permission p WHERE (p.permission_author_id = a.author_id) and (p.permission_blog_id = 8)";
bmk
I was writing when you posted!  :)

You can link the tables together by naming each table:
FROM mt_author a, mt_permission p

I named them "a" and "p", but it can be whatever makes the most sense to you:
FROM mt_author table1, mt_permission table2

When you use them in the select, you also refer to the name of the table then:
SELECT a.author_id, a.author_name......
or SELECT table1.author_id, table1.author_name,


Then you tell the query which fields are linked in the two tables, in this case, author_id:
WHERE (p.permission_author_id = a.author_id)

Ben posted this example for me somewhere around here and it works slick.  smile.gif  I had to ask the first time I tried to link tables up.
kadyellebee
Hey cool, I wasn't far off on my thinking at least - I just didn't quite know how to express it in the correct coding!  I'm off to go try this out smile.gif

Ya know, this could really revolutionize my TRK blog smile.gif  

Next thought on this same thought-train....
Converting my Master Author Archives (current tut on how I do it is here) to MySQL smile.gif  I really would love to figure it out, so maybe once I figure this list thing out, then I'll be on the path to working on that too.  I think that by linking the tables for entries and the authors together, it would be possible.  I'll do some searchign on this too smile.gif

Kristine
kadyellebee
Yep, the list worked out terrifically!  Now i have a list of all my authors emails and webpages, and can stylize it and use it for my main author list! smile.gif

Now how would you suggest spam-protecting that address, since it comes right out of the database - I obviously can't use spam_protect="1".  Hmm, maybe some more research would be good on that on my part... either finding some method of modifying it after it comes from the database or maybe even changing the addresses in the database somehow?  Hmmm...  Maybe I'll leave that out for now.

As for my author archives, I'm thinking that maybe I could set an Array in PHP of all authors (their usernames or author_id) that have permission to post to blog_id=3.  Then set up this so that it does fills in a value of the array as many times as there are authors.
CODE
$listauth1 = "SELECT e.entry_title, e.entry_author_id FROM mt_entry e WHERE (e.entry_author_id = 1) and (e.entry_blog_id = 3)";
$result = mysql_query($listauth1);
while ($row = mysql_fetch_array($result)) {

echo "Author ", ($row['entry_author_id']), ": ", ($row['entry_title']), " <br />\n";
}


That gives me all of the posts that I've created (author_id=1 is me) in blog_id=3 (theredkitchen).

Oh shoot, its time to get ready for work.  I'll work on this more later!!!!  I can't wait, I want to figure this out! smile.gif
The Dead One
Is there anyway to do this without using MySQL?
kadyellebee
A list of authors?  Nope.  Author Archives - you can check out my tutorial, but it still has to be edited every time an author is added or removed.

So the MySQL is by far preferred, now that we have it figured out!! smile.gif

Kristine
The Dead One
Actually I've come kinda close to what I wanted.

I took the script from this thread Comments Leaderboard and changed it ever so slightly to list Authors who've posted at least once and a link to something (it doesn't include Authors who haven't posted it and anyway who cares about them?).  smile.gif

I'm thinking I may use your tutorial to create an Authors Archive including all the Authors and then use this script to link into it from the front page.
T-DoG
QUOTE
Now how would you suggest spam-protecting that address, since it comes right out of the database - I obviously can't use spam_protect="1".  Hmm, maybe some more research would be good on that on my part... either finding some method of modifying it after it comes from the database or maybe even changing the addresses in the database somehow?  Hmmm...  Maybe I'll leave that out for now.


Would it be possible to use the Regex plugin to replace an email address with some javascript code or a server-side script call that would thwart spambots?
bschoate
This thread prompted me to write a new plugin-- MTAuthors. It's available here:

 http://www.bradchoate.com/past/mtauthors.php

Comments/feedback welcome!

Brad
bmk
Wow, amazing again Brad.  Thanks!
The Dead One
This is exactly what I was looking for! smile.gif

The only thing missing is a "number of posts" but it has everything else I was originally looking for! smile.gif

Thanks! smile.gif
bschoate
Ok, 1.1 now supports 'AuthorBlogCount' and 'AuthorEntryCount': MTAuthors 1.1

biggrin.gif
bneupane
QUOTE (The Dead One @ Aug 1 2002, 08:22 AM) *
Actually I've come kinda close to what I wanted.

I took the script from this thread <a href="http://mt.sixapart.com/cgi-bin/ikonboard/ikonboard.cgi?act=ST;f=14;t=5326">Comments Leaderboard</a> and changed it ever so slightly to list Authors who've posted at least once and a link to something (it doesn't include Authors who haven't posted it and anyway who cares about them?). smile.gif

I'm thinking I may use your tutorial to create an Authors Archive including all the Authors and then use this script to link into it from the front page.


Would you mind to share the idea to make the Authors Archive i too am eagerly searching for the same; but till date unable to make so... It would be great help of yours. Thank you
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.