View Full Version : custom fields in my details screen
drhcanada
02-26-10, 08:51 PM
In the "my details area"
is it possible to change the
<table width="100%" cellspacing="0" cellpadding="0" class="frame">
<tr>
<td><table width="100%" border="0" cellpadding="5" cellspacing="0">
{foreach key=num item=customfield from=$customfields}
<tr>
<td width="150" class="fieldarea">{$customfield.name}</td>
<td>{$customfield.input} {$customfield.required}</td>
</tr>
{/foreach}
</table></td>
</tr>
</table>
to something where I can choose the custom fields that are displayed and which ones are non changeable and which ones can be changed.
vchosting
02-27-10, 05:07 PM
I would like the ability to prevent certain custom fields from being updated if possible
drhcanada
02-27-10, 06:25 PM
I simply want to know what code to replace the code noted above with to get certain custom fileds to be listed. I know I would have to do one line per custom field. but this would let me choose to have it editable or simply display.
If you don't want to display all custom fields, why don't you just select the Admin Only on the "Custom Client Fields" page for the fields which you don't want to show to your customers?
drhcanada
03-01-10, 05:36 AM
that would be great but the problem is with the admin only option turned on they cant fill it out on sign up.
I want them to fill the fields out, but I want to manualy choose which ones display in their profile and which are read only versus modifiable.
instead of the whole $customfield.input database calls, I simply want to know how to call specific custom fields in the database
drhcanada
03-09-10, 03:28 PM
nobody has an answer to bring only specific custom fields from the database?
Th following isn't a beautiful solution, but it does the job. Find the customfield foreach in the clientareadetails.tpl, and replace it with something like this:
{foreach key=num item=customfield from=$customfields}
{if $customfield.name neq "Fieldname 1" AND $customfield.name neq "Fieldname 2"}
<tr>
<td width="150" class="fieldarea">{$customfield.name}</td>
<td>{$customfield.input} {$customfield.required}</td>
</tr>
{else}<input type="hidden" name="customfield[{$customfield.id}]" value="{$customfield.value}" />{/if}
{/foreach}
Just replace the Fieldname 1, Fieldname 2 etc. with the fieldnames of the fields you don't want to show.
drhcanada
03-09-10, 09:08 PM
that perfect . thanks.
no idea how to simply call a specific field would you? and ignore all others?
vchosting
03-09-10, 09:14 PM
Will give this ago thanks
that perfect . thanks.
no idea how to simply call a specific field would you? and ignore all others?
You mean to show only to display the fields you give in instead of hiding them? Just rebuild the if-statement a bit:
{foreach key=num item=customfield from=$customfields}
{if $customfield.name eq "Fieldname 1" OR $customfield.name eq "Fieldname 2"}
<tr>
<td width="150" class="fieldarea">{$customfield.name}</td>
<td>{$customfield.input} {$customfield.required}</td>
</tr>
{else}<input type="hidden" name="customfield[{$customfield.id}]" value="{$customfield.value}" />{/if}
{/foreach}
I just got it!
You have two options to make custom fields not editable, in your template code where it says:
First option:
Locate in your code (clientareadetails.tpl):
{$customfield.input}and replace for:
{$customfield.value} it will only display the value of your custom field and not let it be changed
Second option:
replace for:
{$customfield.input|replace:'>':' readonly>'} it will set your input for not editable
The first one will match the "Locked Client Profile Fields" new option.
For showing specifics custom fields I just repeated the custom field code using couple if/else to restrict to certain custom fields:
{if $customfields}
<!-- restrict to specific custom field - start -->
<table width="100%" cellspacing="0" cellpadding="0" class="frame"><tr>
<h3>YOU CAN ADD A TITLE HERE</h3>
<td><table width="100%" border="0" cellpadding="5" cellspacing="0">
{foreach key=num item=customfield from=$customfields}
<tr>{if $customfield.name eq "EXACT-NAME-OF-YOUR-CUSTOM-FIELD-1" || $customfield.name eq "EXACT-NAME-OF-YOUR-CUSTOM-FIELD-2" || $customfield.name eq "EXACT-NAME-OF-YOUR-CUSTOM-FIELD-3"}
<td width="215" class="fieldarea">{$customfield.name}</td>
<td>{$customfield.input} {$customfield.required}</td>
{/if}</tr>
{/foreach}
</table></td>
</tr></table>
<!-- restrict to specific custom field - end -->
<!-- The "EXACT-NAME-OF-YOUR-CUSTOM-FIELD" is case sensitive, if you change in your settings, you must change in the code too.
You can repeat this table for each section of your custom fields, and at the end set up the next one: -->
<!-- show the rest of customfields, if existent - start -->
{if $customfield.name neq "EXACT-NAME-OF-YOUR-CUSTOM-FIELD-1" && $customfield.name neq "EXACT-NAME-OF-YOUR-CUSTOM-FIELD-2" && $customfield.name neq "EXACT-NAME-OF-YOUR-CUSTOM-FIELD-3"}
<table width="100%" cellspacing="0" cellpadding="0" class="frame"><tr>
<h3>YOU CAN ADD A TITLE HERE - FOR EXTRA CUSTOM FIELDS</h3>
<td><table width="100%" border="0" cellpadding="10" cellspacing="0">
{foreach key=num item=customfield from=$customfields}
<tr>{if $customfield.name neq "EXACT-NAME-OF-YOUR-CUSTOM-FIELD-1" && $customfield.name neq "EXACT-NAME-OF-YOUR-CUSTOM-FIELD-2" && $customfield.name neq "EXACT-NAME-OF-YOUR-CUSTOM-FIELD-3"}
<td width="215" class="fieldarea">{$customfield.name}</td>
<td>{$customfield.input} {$customfield.required}</td>
{/if}</tr>
{/foreach}
</table></td>
</tr></table>
{/if} <!-- show the rest of customfields, if existent - end -->
<br />
{/if} <!-- custom fields -->
I just figured out that the first option doesn't work when the user submit the form, it clears out those fields.
I have no idea why.
So just got with the second option.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.