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.

Passing an embed variable to be a parameter

September 16, 2012 5:11am

Subscribe [1]
  • #1 / Sep 16, 2012 5:11am

    jjosephs

    11 posts

    I’m trying to pass the current username variable into an embed template to return a user’s profile image. For some reason the username doesn’t work when it reaches the embed template in the parameter.

    Main

    {exp:comment:form channel="single_life" form_id="commentform" form_class="form"}
     {embed="embeds/_profile_image_for_comments" commenter_user_name="{username}" }
    {/exp:comment:form}

    Embed

    {exp:channel:entries channel="member" limit="1" username="{embed:commenter_user_name}" dynamic="no"}
            {member_photos}
                {if '{primary}'}
                    <input type="text" value='{exp:imgsizer:size image="{image}" width="39" height="39" alt="{title}"}' name="member_thumb_image" />
                {/if}
            {/member_photos}
    {/exp:channel:entries}

    Also, when I experiment with the embed code below, the first username in the database is displayed even though I sent through the logged in user’s name from the main template. Hopefully this might clue you in on the underlying issue.

    {exp:channel:entries channel="member" limit="1" dynamic="no"}
     {embed:commenter_user_name}
            {member_photos}
                {if '{primary}'}
                    <input type="text" value='{exp:imgsizer:size image="{image}" width="39" height="39" alt="{title}"}' name="member_thumb_image" />
                {/if}
            {/member_photos}
    {/exp:channel:entries}
  • #2 / Sep 16, 2012 1:20pm

    Bhashkar Yadav

    727 posts

    Hi Jjosephs,

    If you would like to populate channel data for logged in user then you pass username parameter as username=“CURRENT_USER”.

    Hope this would help you.


    Best Regards,

  • #3 / Sep 16, 2012 3:11pm

    jjosephs

    11 posts

    Thank you, thank solved my issue.

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

ExpressionEngine News!

#eecms, #events, #releases