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.

custom member data fields inside weblog:entries tag

October 11, 2010 11:52am

Subscribe [3]
  • #1 / Oct 11, 2010 11:52am

    James Smith

    259 posts

    I’m trying to output a custom member field from within a weblog:entries loop, but it’s not working. I’ve tried using member_id=”{logged_in_member_id}” as suggested in the comments section of the docs, but this is simply not outputting anything, even when I hardcode a member id as below:

    <ul>
    {exp:weblog:entries weblog="docs"}
       <li>{exp:member:custom_profile_data member_id="18"}{a_custom_field}{/exp:member:custom_profile_data}</li>
    {/exp:weblog:entries}
    </ul>

    Moving that code outside the weblog:entries loop outputs the custom field successfully:

    <ul>
    <li>{exp:member:custom_profile_data member_id="18"}{a_custom_field}{/exp:member:custom_profile_data}</li>
    </ul>

    However I need to be able to pass that member data via an embed along with the current entry_id, so really would like to be able to use it inside weblog:entries.

    Have I missed something?

  • #2 / Oct 12, 2010 10:09am

    Sue Crocker

    26054 posts

    James, which build/version of EE1.x are you using? You can find that at the bottom of any control panel page.

    I can’t replicate the problem you’re having.

  • #3 / Oct 12, 2010 10:12am

    James Smith

    259 posts

    1.6.9, Build:  20100415

  • #4 / Oct 12, 2010 4:59pm

    Sue Crocker

    26054 posts

    Can we have you upgrade to the most recent build?

  • #5 / Oct 13, 2010 1:11pm

    James Smith

    259 posts

    Sorry, upgrading won’t be possible for a while. However, I can now clarify the issue, which is slightly different to what I originally said and might be the reason you were unable to reproduce it… The tag is in fact returning data, but it’s the data from the member that authored the entry, not the logged in member.

    Steps to reproduce

    • Set up two members
    • Set up a custom member field of type text
    • Edit both those members’ profiles so that they have different text in that field
    • Publish a few weblog entries and then set up a template with something like the code below and visit it whilst logged in as each member

    {if logged_in}
    
        <h1>Welcome {username} | {exp:member:custom_profile_data}{a_custom_member_field}{/exp:member:custom_profile_data}</h1>
        {exp:weblog:entries weblog="docs"}
            <li>{title} | {exp:member:custom_profile_data member_id={logged_in_member_id}}{a_custom_member_field}{/exp:member:custom_profile_data}</li>
        {/exp:weblog:entries}
                
    {/if}

    - For me the h1 tag shows the correct data, but the one inside weblog:entries shows the data from the member who authored the entry. I’ve tried all kinds of combinations of apostrohpes, quote marks, braces, and even hardcoding a numerical member_id there doesn’t work.

    Hopefully someone can at least reproduce the error from this (upgrading EE is a pretty major event for this particular site).

  • #6 / Oct 13, 2010 9:00pm

    Sue Crocker

    26054 posts

    Thanks for the more robust troubleshooting steps. Have you seen:

    http://expressionengine.com/legacy_docs/templates/globals/single_variables.html#alternative_syntax

    What happens if you echo out {logged_in_member_id}? Does that work all by itself in your exp:weblog:entries loop?

  • #7 / Oct 14, 2010 5:08am

    James Smith

    259 posts

    Yes, that outputs the correct ID

  • #8 / Oct 14, 2010 6:28am

    James Smith

    259 posts

    Ok, well I’ve found a way of making it work by adding disable=“member_data” to the weblog:entries parameters. This causes me other problems, but I think I can work around them.

    I’m not sure whether this would qualify as a bug, but it’s certainly a bit confusing…!

  • #9 / Oct 14, 2010 9:01am

    Sue Crocker

    26054 posts

    Hmmm… interesting workaround. I’ll add this to the list for regression testing for EE2.1, just to make sure it’s also not in that pipeline.

  • #10 / Oct 14, 2010 9:54am

    James Smith

    259 posts

    I’ve just found a better solution which I didn’t think of before, which is to reverse the wrapping of the tags:

    {exp:member:custom_profile_data}
        <h1>Welcome {username} | {a_custom_member_field}</h1>
        {exp:weblog:entries weblog="docs"}
            <li>{title} | {a_custom_member_field}</li>
        {/exp:weblog:entries}
    {/exp:member:custom_profile_data}

    - This works as expected, though I’m not sure if there’s a performance penalty for wrapping exp:weblog:entries in another tag pair.

  • #11 / Oct 14, 2010 3:04pm

    Ingmar

    29245 posts

    No, I don’t think that should be too bad. Glad to see you’ve got a solution. Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases