INDEXU does an efficient job of processing the custom fields for the link search form and making them available for input during the search process.
However, customizing those custom fields is another matter.
Why customize the custom fields? The primary reason is for select statements or radio buttons ( at least for me ). I have several Yes/No fields and I would like to use radio buttons.
Also, some of my custom fields have several options to chose from. For example, I might have a dropdown list with 5 or six options to choose from.
Here is a hack to customize those fields. Or at least get you started.
The first thing you should know is that if you go elect to do this, it will be a manual process. If you want the custom fields to show up you will manually have to add them ( but see below ).
This hack deals with the link_search process from the Admin screen.
In search_link_form.html
just before
Code:
<%custom_field_form%>
add the following
Code:
<tr class=tbl_light>
<td>Show Detail</td>
<td><%show_det%></td>
</tr>
<tr class=tbl_light2>
<td>Business Type</td>
<td><%bsn_type%></td>
</tr>
In the ShowFormSearchLink function of the link_search.php file:
After
Code:
global $category,$custom_field_form;
Add the following
Code:
// mod to allow customization of the custom fields
global $show_det, $bsn_type;
Change
Code:
$custom_field_form = $links_obj->GenerateCustomFieldForm();
to
Code:
$custom_field_form = $links_obj->GenerateCustomizedField();
Change
Code:
DisplayTemplate($admin_template_path."link_search_form.html","\$category,\$custom_field_form");
to
Code:
$show_det = ShowRadioButton ("show_detail","Yes,No","1,0","");
$bsn_type = ShowDropDown ("bsn_type","---,Free,Commercial,Enhanced","3,2,1,0","");
// mod to allow customization of the custom fields
DisplayTemplate($admin_template_path."link_search_form.html","\$category,\$custom_field_form,\$show_det,\$bsn_type"); Then in the ProcessFormSearchLink() function:
Just before
Code:
elseif(!empty($$field))
$query .= "and $field like '%".$$field."%' "; add
Code:
// mod to allow customization of the custom fields
elseif($field=='show_detail' && $show_detail<>"")
$query .= " and $field = $show_detail ";
// mod to allow customization of the custom fields
elseif($field=='bsn_type' && $bsn_type<>"")
$query .= " and $field = $show_detail ";
Then change the following
Code:
$links_obj->more_param = "&pflag=search&link_id=$link_id&title=$title&url=$url&description=$description
&cat=$cat&contact_name=$contact_name&email=$email&show_detail=$show_detail&bsn_type=$bsn_type.$custom_field_param";
Finally, change the following:
Code:
DisplayTemplate($admin_template_path."link_search_result.html",
"\$num_rows,\$pagination,\$link,\$param,\$show_detail,\$bsn_type"); Then in link.class.php copy the GenerateCustomFieldForm function and paste it just before the very last } at the end of the link.class.php document. Rename it GenerateCustomizedField.
Just after the following,
Code:
$field = $fields[$i];
global $$field; Insert
Code:
if($field == 'show_detail' or $field == 'paid_thru'){}
else{ Several lines down, just before
insert a
For each custom variable, you will follow the same process:
Add it to the link_search_results.html
add it to the ShowFormSearchLink in link_search.php
add it to the ProcessFormSearchLink link_search.php
add it to the new GenerateCustomizedField function in link.class.php
I have edit this from the original to show how to use the automatic generation of all other custom fields.