Documentation

CAdminFilter

Description and methods

The CAdminFilter class is used with the result filter in Control Panel pages.

Methods

Method Description
CAdminFilter The class constructor.
Begin Displays the filter title.
Buttons Displays the filter buttons.
End Ends the filter display.

Example

The following example shows how to set up a filter.

// describe the filter elements
$FilterArr = Array(
	"find_id",
	"find_lid",
	"find_active",
	"find_visible",
	"find_auto",
	);

// initialise the filter
$lAdmin->InitFilter($FilterArr);

// if all filter values are correct, process it
if (CheckFilter()) { // create a filter array for extracting  
    // CRubric::GetList() according to filter values $arFilter = Array( "ID" => $find_id, "LID" => $find_lid, "ACTIVE" => $find_active, "VISIBLE" => $find_visible, "AUTO" => $find_auto, ); } // next, pass in CRubric::GetList() the retrieved array

To display the filter, you have to create a CAdminFilter class instance passing the list of fields to it, and then build the filter form "manually".


// create object filter
$oFilter = new CAdminFilter(
$sTableID."_filter",
   array(
      'find_id' => 'ID',
      'find_lid' => GetMessage("usd_f_site"),
      'find_active' => GetMessage("usd_f_active"),
      'find_visible' => GetMessage("usd_f_public"),
      'find_auto' => GetMessage("usd_f_auto"),
  )
);

<form name="find_form" method="get" action="<?echo $APPLICATION->GetCurPage();?>">
<?$oFilter->Begin();?>
<tr>
  <td><?="ID"?>:</td>
  <td>
    <input type="text" name="find_id" size="47" value="<?echo htmlspecialchars($find_id)?>">
  </td>
</tr>
<tr>
  <td><?=GetMessage("usd_f_site").":"?></td>
  <td><input type="text" name="find_lid" size="47" value="<?echo htmlspecialchars($find_lid)?>"></td>
</tr>
<tr>
  <td><?=GetMessage("usd_f_active")?>:</td>
  <td>
    <?
    $arr = array(
      "reference" => array(
        GetMessage("POST_YES"),
        GetMessage("POST_NO"),
      ),
      "reference_id" => array(
        "Y",
        "N",
      )
    );
    echo SelectBoxFromArray("find_active", $arr, $find_active, GetMessage("POST_ALL"), "");
    ?>
  </td>
</tr>
<tr>
  <td><?=GetMessage("usd_f_public")?>:</td>
  <td><?echo SelectBoxFromArray("find_visible", $arr, $find_visible, GetMessage("POST_ALL"), "");?></td>
</tr>
<tr>
  <td><?=GetMessage("usd_f_auto")?>:</td>
  <td><?echo SelectBoxFromArray("find_auto", $arr, $find_auto, GetMessage("POST_ALL"), "");?></td>
</tr>
<?
$oFilter->Buttons(array("table_id"=>$sTableID,"url"=>$APPLICATION->GetCurPage(),"form"=>"find_form"));
$oFilter->End();
?>
</form> 


© «Bitrix24», 2001-2024