Followers module - Part 3

Friday, January 23rd, 2009

Part 3 of this introduction to the Followers module for ExpressionEngine will show how to display a list of your friends’ entries.

The basic {exp:weblog:entries} tag allows you to use a author_id= parameter to display all entries by a particular author. Multiple authors can be selected by ‘pipe’ separating their ids (eg, author_id=“1|12|34”.

The Followers module can output your list of friends in this format, like so:

{exp:ajw_followers:display show="following" member_id="{segment_3}"}
  {if no_members}-1{/if}
  {members backspace="1"}{member_id}|{/members}

But, there is a problem with supplying this list of authors to the {exp:weblog:entries} tag, as ExpressionEngine runs the {exp:weblog:entries} before the {exp:ajw_followers:display} and so it does not get the list of authors that we want.

To get around this problem we can use an embedded template.

The Solution

We put the basic code to display the list of our friends’ entries in a separate template - called for this example embed_articles_by_author

<h3>Friends' articles</h3>
{exp:weblog:entries weblog="default_site" orderby="date" sort="desc" disable="member_data|trackbacks" dynamic="off" author_id="{embed:authors}"}
{if no_results}No articles by friends{/if}
  <a href="{title_permalink=home/index}">{title}</a> by {author} on {entry_date format="%d/%m/%Y"}

Notice that the author_id= parameter now contains an embed variable, {embed:authors}.

To display this list of friends’ entries, we then need to call the embedded template with the list of authors.

{embed="followers/embed_articles_by_author" authors="{exp:ajw_followers:display show="following" member_id="{segment_3}"}{if no_members}-1{/if}{members backspace="1"}{member_id}|{/members}{/exp:ajw_followers:display}"}

This is just a basic embedded template call but with the {exp:ajw_followers:display} tag being used to populate the authors= parameter. (For safety’s sake, all whitespace between tags has been removed, which makes it look more comlicated than it is.)


The Followers module allows you to create and manage friend relationships between members. These relationships can be used however you wish within ExpressionEngine. Using embedded templates allows you to get around any problems due to the order which templates are parsed.