Add custom button in list view to overwrite the list view search

Hi All ,

i fixed it , m happy to share the solution so here i aim to have button or link to list view on click of that it will give me new list view with status = converted in leads module

so i copy fille from inclue/ searchForm/tpl/SearchFormGeneric.tpl and paste it to folder /custom/include/SearchForm/tpl/SearchFormGeneric.tpl

and added some code in that

    	{if $module eq 'Leads'}
    	&nbsp;&nbsp;<a id="go_select"  href="javascript:void(0);" >Converted </a>

<script type="text/javascript">
$( document ).ready(function() {
   $ ('#go_select').click(function(){
		var newLoc = 'index.php?module=Leads&action=subscriber';
		document.location = newLoc;

add this code be four help icon

so it will check if module is lead than it will show the converted link ( like advance search near to that ) and we have also added on click js function at the end

Do repair and rebuild and see the changes happen

so now on click of the converted link i will redirect to index.php?module=Leads&action=converted

but till now we did not create a action in controller

so create a controller in custom/modules/leads/controller.php file

and add the following code in that

class LeadsController extends SugarController
	public function action_subscriber()
    	$this->view = 'converted';     

so that’s it we have created a controller now and we have specify that what ever comes to this controller it will redirect to view page converted

so now we have to create a view page converted that will give us a list of leads with converted status

so go on and create a file custom/modules/Leads/views/view.subscriber.php

and now we need a list of leads with status converted so that we have to manage here :whistle:


require_once 'modules/Configurator/Configurator.php';

class LeadsViewSubscriber extends ViewList
     * @see ViewList::preDisplay()
    var $where = "leads.status='Converted'";
    public function preDisplay(){

        $this->lv = new LeadsListViewSmarty();

    public function display(){

  	public function listViewProcess()        // genrating listview 
        $this->lv->searchColumns = $this->searchForm->searchColumns;
        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']);
            $configObject = new Configurator();
            $configObject->config['save_query'] = 'no';
            echo $this->lv->display();

so mainly we are setting where condition over here so list will generate with that condition

and we have are updating the gable config save_query =‘no’ so every time when page loads i will start from pagination offset 0

so that’s it Do repair and rebuild and see the changes :cheer: :slight_smile:

i hope this helps


I was going to suggest that you need to build an entirely custom view to output the results. Well done :wink: