-->

Search option is removed after adding Where condit

2019-09-02 19:13发布

问题:

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();
}
}

回答1:

You are using function AccountsViewList instead of ContactsViewList.

Also you will have to copy function prepareSearchForm() from include/MVC/View/views/view.list.php to show your search form.



回答2:

$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()