Getting the Blogs of an Author in Movable Type

| No Comments | No TrackBacks |
Getting the authors of a blog in Movable Type is not that hard: just use the <mt:authors> tag when you are in blog context, and the list of authors will roll right out.  But what if you need to find the opposite?  Given an author, which blogs does he have a role on?
I was recently faced with this question for a project, and there didn't seem to be a tag or attribute readily available for this sort of thing.  So after I submitted a feature request, I cooked up this little tidbit:

Blogs by Maarten Schenk:
<mt:blogs>
<mt:authors>
<mt:if tag="authordisplayname" eq="Maarten Schenk"><li><mt:blogurl></li></mt:if>
</mt:authors>
</mt:blogs>​

This results in a nice list of all blogs on which I have a role in this installation:

Blogs by Maarten Schenk:
  • http://www.movabletips.com/
  • http://www.movabletips.com/test/
  • http://www.yesitcan.be/

  • If you put following snippet in a context where an author is present (for example, an entry, an author archive...) you can generate the list for any arbitrary author:

    <mt:authordisplayname setvar="thename">
    Blogs by <mt:var name="thename">:
    <mt:blogs>
    <mt:authors>
    <mt:if tag="authordisplayname" eq="$thename"><li><mt:blogurl></li></mt:if>
    </mt:authors>
    </mt:blogs>​

    For installations with up to a few hundred blogs or authors this should prove workable.  Any larger, and the authors loop inside the blogs loop  might slow down publishing. In cases like that it is probably a good idea to use a special author archive for each author which outputs this list in a file with the name or ID of the author in the filename, and then to include this file whenever the list of blogs for that author is needed. 

    No TrackBacks

    TrackBack URL: https://www.movabletips.com/cgi-bin/mt/mt-tb.cgi/94

    Leave a comment