Using Designer V4.1.9 with the default template Hi, I have setup parent child extra fields for Location (parent field), State and Country (both child fields). The Extra field names and ID’s for each are as follows: Location: id 11 (Parent) State: id 12 (child) Country: id 13 (child) I’m trying to ad a single column to the showlistings.tpl to display either the State or the Country and have been unsuccessful using the following code. Code: {if {get_extra_field id=$entry.id fid=11} $entry.title==" State"} <td{if $entry.class<>""} class="{$entry.class}"{/if}>{get_extra_field id=$entry.id fid=12}</td> {else} <td{if $entry.class<>""} class="{$entry.class}"{/if}>{get_extra_field id=$entry.id fid=13}</td> {/if} I think the issue is in the first line however I'm not sure what the correct statement should be. Any help would be much appreciated. Thanks
You can't do it like this in smarty. I seem to remember that you can't assign either to a variable and then make the test either in a direct manner. There are a couple of threads dealing with this http://www.68classifieds.com/forums/customizations/8854-assign-extra-fields-variable.html http://www.68classifieds.com/forums/technical-support/8797-assigning-variables-2.html
Thanks for the response Seymourjames. I tried the following code from the link you provided and using capture worked, however the results always returned for {else} in the showlistings.tpl display. Code: {capture name='loc'} {get_extra_field id=$entry.id fid=11} {/capture} {if $smarty.capture.loc=="United States"} <td{if $entry.class<>""} class="{$entry.class}"{/if}>{get_extra_field id=$entry.id fid=12}</td> {else} <td{if $entry.class<>""} class="{$entry.class}"{/if}>{get_extra_field id=$entry.id fid=13}</td> {/if} The parent extra field named Location, id 11, has two values: 1. United States - sub ID 12 2. International - sub ID 13 I’m not a programmer but it seem as though the line {if $smarty.capture.loc=="United States"} is not working thus resulting in the return of {else}.
I would try doing it the other way where you embed the test in a copy of that plugin- see the other thread.
Thanks again Seymourjames. Unfortunately tweaking the suggested plug in to get the desired output is beyond my limited programming skills. I do appreciate you trying to help. I did eventually figure out a simpler solution and am posting it here to close this thread. Since a user can only select one of the child fields, the unselected field would be blank. I inserted the following code into the template and it seems to be working just fine. Code: <td{if $entry.class<>""} class="{$entry.class}"{/if}>{get_extra_field id=$entry.id fid=12}{get_extra_field id=$entry.id fid=13}</td>