Abhi Adr Abhi Adr - 11 months ago 159
Smarty Question

Search option is removed after adding Where condition to list view suitecrm/sugarcrm?

I want to customize the list view based on condition so i followed this blog to add where condition in list view

Developer Blog From Sugar where clause for sugar list-view pages

but after doing this i am not getting search options in my custom list view. Can any one guide me on this?

Following is the modified list view(i followed mentioned blog for this)

<?php

require_once('include/MVC/View/views/view.list.php');
require_once('custom/modules/Contacts/ContactsListViewSmarty.php');

class ContactsViewList extends ViewList
{
/**
* @see ViewList::preDisplay()
*/
var $where = "";
function AccountsViewList()
{
parent::ViewList();
}


public function preDisplay(){
require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::LVPopupHtml('Contacts');
parent::preDisplay();
if($_GET['parentTab']=='Sales'){
$this->where .= "contacts.title ='IT Developer'";

}elseif ($_GET['parentTab']=='Marketing') {
$this->where .= "contacts.title ='Director Sales'";

}
$this->lv = new ContactsListViewSmarty();
}

function listViewProcess()
{
$this->lv->setup($this->seed, 'include/ListView/ListViewGeneric.tpl', $this->where, $this->params);
echo $this->lv->display();
}
}

Answer Source
$this->processSearchForm();                             // for search form 
    $this->lv->searchColumns = $this->searchForm->searchColumns;
    if(!$this->headers)
        return;
    if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
        $this->lv->ss->assign("SEARCH",true);
        $this->lv->setup($this->seed, 'include/ListView/ListViewGeneric.tpl', $this->where, $this->params);                   // call the listview's file 
        $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);              // save the last search 
        echo $this->lv->display();              // display your search 

this code should be in listViewProcess()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download