Replace username with Real Name

Discussion in 'Templates, HTML, CSS, and Design Help' started by pickyourownpet.com, Jan 26, 2011.

  1. v4.1.10 Developer

    Hi,

    I have read a lot about "{capture name='foo'}" and a few other if/then statements, but I can't seem to make this work.

    I have an Extra Field fid=13. This field is a simple Yes/No Dropdown. If selected Yes while placing an Ad, I wish for the username to be replaced with the user's real first and last name.

    Any simple ideas?

    I need this in Viewlistings2.
  2. Blair Moderator

    The "Get extra field" feature was introduced in 4.1.10. It may help you accomplish what you're describing: Get Extra Field - 68 Classifieds

    But, since you're trying to trigger an 'if-else' with the value of an extra field and you have the developer version, my first inclination is to place all the coding (SQL and PHP) in the php files instead of working with Smarty syntax.
  3. Blair, Thank you for the link. I read more, and found a couple more threads to help me. I am not a genius with SQL,PHP Smarty or anything like that. I am learning though.

    I have a dropdown box with options 'Yes' or 'No'. If selected yes, I want the Username replaced with the User's First and Last Name.

    I have the following, and I think I just need a second or third pair of eyes to evaluate this. What might I be doing wrong?

    Code:
    {capture name='firstlast'}
     {get_extra_field id=$entry.id fid=13}
     {/capture}
     {if $smarty.capture.firstlast=="Yes"}
     {if $entry.class<>""} class="{$entry.class}"{/if}><a href="viewmember.php?member={$owner}">{$fname}{$lname}</a>
     {else}
     <a href="viewmember.php?member={$owner}">{$username}</a>
     {/if}
    
    It only returns the 'else' and displays the user name still.

Share This Page