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}}
I think you may need to use capture: Smarty Code: {capture name='foo'} {get_extra_field id=$view fid=28} {/capture} {$smarty.capture.foo}
The very end of this thread may be of interest. It is basically a custom plugin that acts on the logic you put into it. In this case, it will display and image if an extrafield (checkbox) is clicked but you could evaluate any type of extrafield. http://www.68classifieds.com/forums/v4-1-questions-support/8797-assigning-variables-2.html
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?
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.
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.
Try it first with a checkbox an then with other types of extrafields; The principle should be the same.