You can now add custom fields without any php coding. Just administrate your fields and display them in the templates, where you want.
How to create a new custom field?
Just follow this simple steps:
- Enter the Custom Fields Administrator in Component Administration: "Settings" / "Custom Fields" menu icon.
- Hit the "New" menu in the toolbar and enter your new field properties.
- Compulsory settings for functioning are the label, db name, type and section. In the screenshot it's been created a Zip code field for a Auction item. You can create custom fields for auctions and users (for the latter only if CB is not used). Also you can select the propper field type from the list: textbox, textarea, select list, radio, editor. Some types of fields require extra parameters to setup. The list types require the options to be stored to.
How to display the new created custom filed?
First of all if you are an inexperienced user, we recommend to check first our template tutorial. There are four places where you may want to customize your fields appearance.
- Edit Forms
The fields are automatically displayed by the code blocks for "user profile" and "auction":
1. bids.html.php / editUser() or editAuction() method
/**
* CUSTOM Fields
*/
$Fi = & FactoryFieldsFront::getInstance();
$fields = $Fi->getHTMLFields(__SECTION__, $user->userid);
$smarty->assign("profiler", $fields);
OBS: __SECTION__ is one of "user_profile" or "bids".
2. t_myuserdetails.tpl or t_editauction.tpl
{foreach from=$profiler item=field}For manual positioning in the template just display the {$profiler} smarty list element that you want:
<tr>
<td>{$field.field_name}</td>
<td>{$field.field_html}</td>
</tr>
{/foreach}
{$profiler.0.field_name}: {$profiler.0.field_html}
- Display on auction / user page
On the auction page (t_auctiondetails.tpl) you can manually add your fields by inserting {$auction->custom_field_db_name}.
{$auction->my_custom_field_db_name}
or in the user page (t_userdetails.tpl) the same but the smarty variable name is {$user->my_custom_field_db_name}
- Display on search page
By default the fields setup as searchable are displayed automatically by this sequence of smarty in the t_search.tpl:
{foreach from=$profiler item=field}
<tr>
<td>
<table>
<tr>
<td>{$field.field_name}</td>
<td>{$field.field_html}</td>
</tr>
</table>
</td>
</tr>
{/foreach}
- Display on auction list page
Auction fields can be manually added in the list template in the specific/ desired list template cell: t_listauctions_cell.tpl / t_myauctions_cell.tpl / t_mybids_cell.tpl / t_mywatchlist_cell.tpl / t_mywonbids_cell.tpl
<div>You can choose to display the field as a filter link:
<span>ZIP</span>
<span >
{$current_row->zipcode}
</span>
</div>
<div id="auction_date">
<span>{$smarty.const.bid_start_bid_text}</span>
<span id="auction_price_bold">
{$current_row->initial_price|string_format:"%.2f"} {$current_row->currency_name}
</span>
</div>
<div>
<span>ZIP</span>
<span >
<a href="index.php?option=com_bids&task=showSearchResults&zipcode=
{$current_row->zipcode}">
{$current_row->zipcode}
</a>
</span>
</div>
<div id="auction_date">
<span>{$smarty.const.bid_start_bid_text}</span>
<span id="auction_price_bold">
{$current_row->initial_price|string_format:"%.2f"} {$current_row->currency_name}
</span>
</div>