Extending/Customize List View

Today We came across a forum question which asked to hide “Closed Lost” opportunities from list view.

Simple steps and you are through!

Step 1: Create or edit custom/modules/Opportunities/views/view.list.php and add following code,

<?php

require_once('include/MVC/View/views/view.list.php');

class OpportunitiesViewList extends ViewList {

    function listViewProcess() {
        global $current_user;
        $this->processSearchForm();
        if(!$current_user->is_admin) // remove this condition if you dont want admin user to view the "Closed Lost" Opportunities.
            $this->params['custom_where'] = ' AND opportunities.sales_stage <> "Closed Lost" ';
       
        if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) {
            $this->lv->setup($this->seed, 'include/ListView/ListViewGeneric.tpl', $this->where, $this->params);
            $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
            echo $this->lv->display();
        }
    }

}

Step 2: Refresh list view!

Note :

P.S. Possible customizations in the query are:
> custom_select 
> custom_from 
> custom_where 
> custom_order_by
Order by will be considered as second order by field when user clicks on other field to sort records.

Hope this helps and feels like missing piece is just found!

Feel free to drop your comments.

Your valuable feedback means a lot.

You can contact us at info@infotechbuddies.com

Thank you.

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *