Results 1 to 5 of 5

Thread: Hack to customize the custom fields

  1. #1
    esm's Avatar
    esm
    esm is offline Active Member
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default Hack to customize the custom fields

    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
    Code:
    $i++;
    insert a
    Code:
    }
    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.
    Last edited by esm; 05-28-2003 at 07:38 AM.
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  2. #2
    dody is offline Administrator
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,731

    Default

    Thanks esm, this is another solutions from the one written in techical notes (under title: creating radio button and drop down menu).
    www.nicecoder.com
    www.dodyrw.com

  3. #3
    esm's Avatar
    esm
    esm is offline Active Member
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    Originally posted by dody
    Thanks esm, this is another solutions from the one written in techical notes (under title: creating radio button and drop down menu).
    Yep, I saw that in one of your posts the other day AFTER I had posted this. I may still finish it up as I need it in the link_search module.

    Do you have any suggestions?
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  4. #4
    dody is offline Administrator
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,731

    Default

    www.nicecoder.com
    www.dodyrw.com

  5. #5
    esm's Avatar
    esm
    esm is offline Active Member
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    I have updated the hack to allow the use of the autogenerate feature.
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

Similar Threads

  1. Replies: 1
    Last Post: 11-04-2003, 12:47 PM
  2. Ability to search custom fields
    By Hart_House in forum v3.2
    Replies: 1
    Last Post: 08-07-2002, 02:38 AM
  3. Replies: 1
    Last Post: 06-24-2002, 07:23 PM
  4. Are the custom fields searchable?
    By Phil Latio in forum v5.x
    Replies: 0
    Last Post: 02-04-2002, 11:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •