User Documentation

User:Authors template tag

The User:Authors tag enables you to display the Related Authors that have been assigned to a given entry.

{exp:user:authors} content {/exp:user:authors}

Parameters

The following parameters are available for use:

entry_id=

entry_id="{entry_id}"

This parameter is required to run the User:Authors tag. You can feed it the entry ID from the Channel:Entries tag or an entry ID from the URI.

orderby=

orderby="primary"

This parameter allows you to order your authors list by screen name, or show the primary author first or last.

sort=

sort="desc"

This parameter controls whether you want screen name ordered entries sorted by asc or desc, or if you want primary authors to show first or last.

Variables

Most of the variables available in the User:Profile tag are available here. Additionally, these exist as well:

primary

{if primary == "y"}
    (Primary)
{/if}

This variable parses to y or n. Assigning a primary author of an entry is done so in the CP Publish page for the given entry by making it first in the list. The likely usage for this variable is as a conditional, which allows you to display alternate text, CSS class or image.

Conditionals

The variables above are available as conditionals. Additionally, these exist as well:

user_no_results

{if user_no_results}
    Sorry, no results were found.
{/if}

This conditional displays its contents when there are no results.

Examples

Typically, you’ll need to embed the User:Authors tag into a Channel:Entries loop, like in the example below.

{exp:channel:entries}
    <h2>{title}</h2>
    <p>{body}</p>
    <h4>Authors:</h4>
    {embed="user/authors_embed"
        entry_id="{entry_id}"
    }
{/exp:channel:entries}

Your embedded User:Authors template would look something like this:

<ul>
{exp:user:authors
    entry_id="{embed:entry_id}"
    dynamic="no"
}
    <li{if primary == "y"} class="primary"{/if}>{screen_name}</li>
{/exp:user:authors}
</ul>

If you’d like to show the native EE author if there are no Related Authors for the entry, your code might look like this:

Main Template

{exp:channel:entries}
    <h2>{title}</h2>
    <p>{body}</p>
    <h4>Authors:</h4>
    {embed="path_to/embed"
        entry_author="{author}"
        entry_id="{entry_id}"
    }
{/exp:channel:entries}

Embedded Template

<ul>
{exp:user:authors
    entry_id="{embed:entry_id}"
    dynamic="off"
}
    <li{if primary == "y"} class="primary"{/if}>{screen_name}</li>
{if user_no_results}
    <li>{embed:entry_author}</li>
{/if}
{/exp:user:authors}
</ul>

Support

Having problems setting up and/or using User? Support is offered from 10am to 4pm EST weekdays. Send us an email at help@eeharbor.com and we will respond as quickly as we can.