2

I have a template for logged-in users where there's a small sidebar in which I want to display the member's photo. In the EE documentation, it says to to use the {photo_url} variable, along with {photo_height} and {photo_width}. Unfortunately, when I put those into my template, EE doesn't even render them. Am I missing a {exp:} wrapper tag?

Here's what I have now:

{exp:member}
 {if photo}
  <div style="background:url({photo_url}); width:141px; height:156px" ></div>
 {if:else}
  <div style="background:url('/images/img1.jpg'); width:141px; height:156px" ></div>
 {/if}
{/exp:member}

As it is now, the entire block seems to be erroring out and displaying nothing, however if I remove the {exp:member} tags, it always evals to false. I know I have a photo uploaded for the member that I'm testing with, and if I remove the {if} block and just leave in {photo_url} it prints the literal value "{photo_url}".

What am I missing?

2

You might use following code:

{exp:member:custom_profile_data}
 {if photo}
  <div style="background:url({photo_url}); width:141px; height:156px" ></div>
 {if:else}
  <div style="background:url('/images/img1.jpg'); width:141px; height:156px" ></div>
 {/if}
{/exp:member:custom_profile_data}

Take a reference from the doc http://ellislab.com/expressionengine/user-guide/modules/member/#custom-profile-data-tag

| improve this answer | |
  • That's great, thanks! I assumed that the custom_profile_data was for custom member fields, and not for standard-built in ones... thanks! – nageeb Jun 28 '13 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.