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.

Getting author_id from custom field as parameter for channel entry

April 21, 2012 4:47am

Subscribe [2]
  • #1 / Apr 21, 2012 4:47am

    kenny2

    90 posts

    I have a channel I use for staff profiles. One of the custom fields (usr_author_id} in this channel holds the author_id related to that user.

    On a single entry page I would like to show a profile plus all posts made by that person, but I am struggling to find the method for grabbing the author_id. I am aware that I cannot have a channel entries tag inside another, and I would rather avoid having the author id in the url so would a query inside the channel entries tag work.. something like this?

    {exp:channel:entries channel="profiles" dynamic="off" author_id="{exp:query… }{usr_author_id}{/exp:query}"}
  • #2 / Apr 22, 2012 1:40pm

    Rob Allen

    3114 posts

    If you’re viewing a single entry page (eg a profile page) then you’d need something in the URL to grab that persons profile info? Often that’s their username (/profile/fred) or member ID (/profile/24)

    If that’s the case then you can simpl use the URL segment as the author ID

    Using member ID:

    {exp:channel:entries limit="10" author_id="{segment_x}"}
        <h2>{title}</h2>
    <p>    {body}<br />
    {/exp:channel:entries}

    Using username:

    {exp:channel:entries limit="10" username="{segment_x}"}
        <h2>{title}</h2>
    <p>    {body}<br />
    {/exp:channel:entries}

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

ExpressionEngine News!

#eecms, #events, #releases