Assign Extra fields to Variable

Discussion in 'Customizations' started by pipelin, Nov 7, 2009.

  1. pipelin Customer

    Hi,

    I'm trying to assign an extra field value to variable in viewlisting.tpl, but the variable store "get_extra_field"

    Code:
    {get_extra_field id=$view fid=28} 
    [COLOR=Blue]{assign var=something value=get_extra_field id=$view fid=28}[/COLOR]
    {$something}
    {if $something=="Yes"}
    
    Someone know how I can assign this value to variable?

    Note:
    this doesn't work
    Code:
    {assign var=something value={get_extra_field id=$view fid=28}}
  2. Eric Barnes Guest

    I think you may need to use capture:
    Smarty

    Code:
    {capture name='foo'}
    {get_extra_field id=$view fid=28}
    {/capture}
    {$smarty.capture.foo}
    
  3. seymourjames All Hands On Deck

  4. pipelin Customer

    Thanks,

    Capture works, but there is something else with the extra field.

    When I print {$smarty.capture.foo}
    "Yes" is in the variable,then I do

    {if $smarty.capture.foo=="Yes"}
    Show data
    {else}
    Show image
    {/if}

    But it always selects {else}. I think the extra field has spaces or something and I don't know how handle it.

    Some idea?
  5. Lhotch curmudgeon

    variables contents and in turn comparisons include capitalization, spaces etc.

    So you need be sure the value of foo has no spaces and the Y is capitalized.
  6. pipelin Customer

    Just I created a drop down Yes or No extra field.
  7. Lhotch curmudgeon

    And what have you dont to make sure the value of foo doesnt have a space before or after it?
  8. pipelin Customer

    No, I'm not sure where the spaces are.
  9. seymourjames All Hands On Deck

    The plugin I suggest for doing this should work fine; You just put the something and something else in around the $check variable at the bottom; 10 seconds to try. You can even echo out the $check variable each time to see what it contains. The advantage to doing it this way is it will keep your original code cleaner anyway.
  10. pipelin Customer

    I'll try in that way thanks
  11. seymourjames All Hands On Deck

    Try it first with a checkbox an then with other types of extrafields; The principle should be the same.

Share This Page