Tom,
in short the best way to accomplish something is based on many factors beyond just your desired result.
As someone new to
68C I can understand why you dont see the bigger picture but you also need to understand that many of the things you think dont matter are actually key issues in the decision process of how best to proceed.
As a developer we are constantly faced with these challenges, people think Oh he can write code this will be easy. Sometimes it is, sometimes is deceptivly complex but for those not in our shoes they take it for granted.
Now back to your 'problem', now that I know what we are dealing with the solution is not that difficult. As I have already stated, the extra fields are presented to the template as an array of data, the array is looped over and each item is checked to se if it has a value and if it does its displayed.
so, look a the debug console to see your extra fields.....
look at the viewlistoing.tpl template to see the section that loops over
PHP Code:
{* Extra Fields *}
{foreach from=$extrafields item=extras}
<tr>
<td><strong>{$extras.title}:</strong></td>
<td>
{if isset($extras.value)}
{foreach key=key item=item from=$extras.value}
{$item|nl2br}<br />
{foreachelse}
{$extras.value}
{/foreach}
{/if}
</td>
</tr>
{/foreach}
{* End Extra Fields *}
Okay, so now you have an extra field called "List Type" or what ever you named it, its a dropdown list with fixed choices.
The template variable $extrafields is actually a multidimentional array or group of arrays within an array. The smarty foreach loop says that its going to break dow the $extrafields multidimensional array into single arrays and for each array its going to display values.
The first thing in the loop an table row is created, then a data cell to hold the title of the exta field. If you want to have your extra field called "list type" not to be displayed in the ad for the client to see then what would you do? You have 2 options, set the extra field to not be seen in the ad OR use logic to check for the extra field in the foreach and dont display it if its encountered. If you set the field to not be displayed then the data wont be there to evaluate against so I would probably opt for the later.
So now, if we are only concerned with the output and value of that one extra field and they are all being looped over, then all we have to do is ad a logic check in the existing loop to see if the current loop iteration is the extra field in question. Its important to note that the table row is created first after the foreach loop starts so if we dont want a row added if our "list type" extra field is encountered we would want to put the logic before the opening TR tag.....something like this...
PHP Code:
{* Extra Fields *}
{foreach from=$extrafields item=extras}
{if $extras.title != "List Type"}
<tr>
<td><strong>{$extras.title}:</strong></td>
<td>
{if isset($extras.value)}
{foreach key=key item=item from=$extras.value}
{$item|nl2br}<br />
{foreachelse}
{$extras.value}
{/foreach}
{/if}
</td>
</tr>
{/if}
{/foreach}
{* End Extra Fields *}
So above3 all I did was say if the title of the current extra field being looped over IS NOT "List Type" then proceed, create the table row and data cells etc. That will allow all of your extra fields, regardless of how unique or many to be displayed by the list type field will not be.
Ok, but maybe you dont actually want to hide the field, just change the vale of the extra field depending on its current setting, thats simple enough to do by simply replacing the bottom {/if} I added with an else and then adding in your needed logic to look at the value of the drop down and output what is desired.
PHP Code:
{* Extra Fields *}
{foreach from=$extrafields item=extras}
{if $extras.title != "List Type"}
<tr>
<td><strong>{$extras.title}:</strong></td>
<td>
{if isset($extras.value)}
{foreach key=key item=item from=$extras.value}
{$item|nl2br}<br />
{foreachelse}
{$extras.value}
{/foreach}
{/if}
</td>
</tr>
{else}
<tr>
<td><strong>{$extras.title}:</strong></td>
<td>
{if isset($extras.value)}
{foreach key=key item=item from=$extras.value}
{$item|nl2br}<br />
{foreachelse}
{if $extras.value == "Give Away"}
Free to Good Home.
{elseif $extras.value =="Sell"}
{$price|format_money}
{/if}
{/foreach}
{/if}
</td>
</tr>
{/if]
{/foreach}
{* End Extra Fields *}