我想根据条件自定义列表视图,所以我按照这个博客添加列表视图中的where条件
Developer Blog From Sugar where clause for sugar list-view pages
但在执行此操作后,我无法在自定义列表视图中获取搜索选项。任何人都可以指导我吗?
以下是修改后的列表视图(我之后提到了博客)
<?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();
}
}
答案 0 :(得分:2)
您使用的是AccountViewList函数而不是ContactsViewList。
此外,您还必须从include / MVC / View / views / view.list.php复制函数prepareSearchForm()以显示您的搜索表单。
答案 1 :(得分: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()
中