0

我想根据条件自定义列表视图,所以我按照这个博客在列表视图中添加 where 条件

开发人员博客来自 Sugar 列表视图页面的 where 子句

但这样做之后,我没有在我的自定义列表视图中获得搜索选项。有人可以指导我吗?

以下是修改后的列表视图(我为此关注了提到的博客)

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

2 回答 2

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 

这段代码应该在 listViewProcess()

于 2014-12-08T05:44:05.813 回答
2

您正在使用函数 AccountsViewList 而不是 ContactsViewList。

您还必须从 include/MVC/View/views/view.list.php 复制函数 prepareSearchForm() 以显示您的搜索表单。

于 2014-11-10T06:32:26.303 回答