ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Limit content dynamically by author…

April 11, 2011 11:07am

Subscribe [4]
  • #1 / Apr 11, 2011 11:07am

    gazaston

    128 posts

    I’m developing a site that features a variety of channels, each displayed on a main template (“profile”) via embeds.

    The site will have a member group of authors.

    The main template needs to display entries in all those channels from only one author at a time, based on URL.

    e.g. http://www.website.com/bloggers/profile/author

    Is this possible?

  • #2 / Apr 11, 2011 12:15pm

    Mark Bowen

    12637 posts

    If you take a look at the username=”“ parameter then this should help you to get what you need.

    Hope that helps a bit.

    Best wishes,

    Mark

  • #3 / Apr 11, 2011 4:04pm

    gazaston

    128 posts

    Thanks Mark,

    Looks like that might be the ticket, but I don’t know how to go about using it dynamically.

    For example, here’s the embedded template for blog entries (with username=”” hard-coded in):

    {exp:channel:entries channel="blog" limit="8" dynamic="off" username="John Smith"}
    
    <article class="blog-entry">
    <h3>{title}</h3>
    <p><date>Posted on {entry_date format="%d %M %Y"}</date></p>
    
    <p>{body}</p>
    
    <p></article></p>
    
    <p>{/exp:channel:entries}

    That seems to work okay for that one user. It’s being pulled into the main template (“profile”) with:

    {embed="channels/blog" dynamic="off"}

    There’s a nav menu (populated by it’s own channel) with links to each blogger’s “profile” page:

    {exp:channel:entries channel="bloggers" dynamic="off"}
    
    <div><a href="http://{title_permalink=">{title}</a></div>
    
    {/exp:channel:entries}

    I guess the Username parameter would need to be used dynamically in one of those bits of code somewhere?

  • #4 / Apr 11, 2011 4:16pm

    Kevin Cupp

    791 posts

    I’ve achieved this by passing in a segment variable from the permalink to the channel module. For example, my company’s blog: http://insidenewcity.com/blog/ We’re displaying a list of EE users with the User module (EE 1.6, maybe available for 2?), and linking it to blog/author/{username}. Then in the author template, we put username=”{segment_3}” in the weblog:entries tag.

  • #5 / Apr 11, 2011 9:24pm

    Sue Crocker

    26054 posts

    Thanks for the assist, Kevin and Mark.

    Using username=”{segment_3}” is the way to go here.

  • #6 / Apr 12, 2011 7:26am

    gazaston

    128 posts

    Thanks all, I almost fully understand how to do this now.

    But how do I get usernames into a URL-friendly format? The usernames are John Doe, Jane Doe rather than john-doe, jane-doe etc.

    Is that why I’ll need Solspace’s User?

    EDIT: I tried changing the actual usernames to url-friendly format and that works fine but I’d like to keep semantic usernames if at all possible?

  • #7 / Apr 13, 2011 12:43pm

    Sue Crocker

    26054 posts

    When you say semantic username, are you meaning the screen_name?

    Here’s an example:

    billybob is a username
    Billy Bob Thornton is a screen_name

    The author field uses a member_id which is set to match with the username you pass to it.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases