Results 1 to 7 of 7

Thread: creating custom button on listview

  1. #1
    blqt is offline Member
    Join Date
    Aug 2008
    Posts
    7

    Default creating custom button on listview

    Hi,

    I have successfully created a custom button on the Accounts List View.
    Basically, the purpose is to add a button similar to the export button.
    I copied and adapted the generic view.list, ListView.tpl and ListViewPagination.tpl in custom/modules/Accounts

    I added the following code in ListViewPagination.tpl:
    <input id='print_contacts_link' class="button" type='button' value="Export contacts" onclick="return sListView.send_form(true, 'Accounts', 'contactsreport.php','You must select at least one account.')">

    It works fine, but I am wondering if I did it the best way:
    - it might require some changes when upgrading SugarCRM
    - there is no way to use different languages for the button or the error message.

    Is there a way to add a button in custom/modules/Accounts/metadata/listviewdefs.php (or in another location) ? What would be the syntax to do that?

    My configuration:
    - Community Edition 5.0.0g
    - Windows XP
    - Apache, PHP5, MySQL

    Thanks in advance,
    Benoit

  2. #2
    jibouille58 is offline Member
    Join Date
    Sep 2008
    Posts
    9

    Default Re: creating custom button on listview

    And to delete the "export" button of Tasks for example or the "compose a mail" of contacts, how you make please ?

  3. #3
    Rudi Mentär is offline Senior Member
    Join Date
    Sep 2008
    Posts
    157

    Default Re: creating custom button on listview

    i would also like to remove the export button in only one module - how can i do that?

  4. #4
    dlorenzetti's Avatar
    dlorenzetti is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    São Paulo, Brasil
    Posts
    189

    Default Re: creating custom button on listview

    Hello All,

    to remove the export button you can do that:

    in custom/modules/Accounts/views/view.list.php

    PHP Code:
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

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

    class 
    AccountsViewList extends ViewList {

         function 
    preDisplay(){
             
    $this->lv = new ListViewSmarty();

             
    $this->lv->delete false;
         }


    and to create a button one good idea is in this same file (view.list.php) you do that:

    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

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

    class 
    AccountsViewList extends ViewList {

         function 
    listViewProcess(){
            
    $this->processSearchForm();
            
    $this->lv->searchColumns $this->searchForm->searchColumns;
            
            if(!
    $this->headers)
                return;
            if(empty(
    $_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
                
    $this->lv->setup($this->seed'custom/include/ListView/ListViewIntegration.tpl'$this->where$this->params);
                
    $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' $_REQUEST['saved_search_select_name']);
                echo 
    get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName''false);
                echo 
    $this->lv->display();
            }
         }
    }
    ?>
    you can see in this line:
    $this->lv->setup($this->seed, 'custom/include/ListView/ListViewIntegration.tpl', $this->where, $this->params);

    I change the tpl file, in this tpl you can call you custom pagination tpl with the new button.
    Diego Lorenzetti
    Lampada Global Services - Open Source Solutions
    Phone: +55 11 3237-3110
    Email: equipe@lampadaglobal.com
    Site: www.lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

  5. #5
    Rudi Mentär is offline Senior Member
    Join Date
    Sep 2008
    Posts
    157

    Default Re: creating custom button on listview

    thx a lot !
    works perfect!

  6. #6
    changfoot is offline Member
    Join Date
    May 2010
    Posts
    17

    Question Re: creating custom button on listview

    Hi guys,

    I'm trying to do a similar thing.

    Except instead of removing a button and playing with the pagination.tpl, I want add an icon next to an account name in the account module list view.

    I've tried this a couple of ways, but I'm getting stuck.

    If I follow something similar to the above:


    1. Create a custom/modules/Accounts/views/view.list.php

    2. How/Where would I point to the ListViewGeneric.tpl (this is the listing TPL right?)

    In the example above you render a custom view for the pagination.tpl, which is included by the generic.tpl within /includes/ListView.


    Please give me some input... really appreciate it!


    Thanks!


    T

  7. #7
    Join Date
    Nov 2010
    Posts
    8

    Default Re: creating custom button on listview

    Hello All

    I have created a custom module called CP_CustomButton.In that module i have created a custom button in the edit view named "Save as text file". The code for that in editviewdefs.php is as follows:

    array (
    'form' =>
    array (
    'buttons' =>
    array (
    0 => 'SAVE',
    1 => 'CANCEL',
    2 => 'DELETE',
    3 =>
    array (
    'customCode' => '<input title="Save File" accessKey="a" type="button" class="button" onClick="document.location=\'index.php?module=CP_C ustomButton&action=SaveFile\'" name="SaveToFile" value="SaveToFile">',
    ),
    ),
    ),


    For the "Save File" action the code in controller.php is as follows:

    <?php

    class CP_CustomButtonController extends SugarController {

    function action_SaveFile()
    {
    // write the php code here
    $fname = $this->module;
    $description = $_REQUEST['description'];
    $name = $_REQUEST['name'];

    $fp = fopen("c:/myfile.txt","w") or exit("unable to open the file");
    if($fp != null)
    {
    fwrite($fp,$fname);
    fwrite($fp,"\n");
    fwrite($fp,$name);
    fwrite($fp,"\n");
    fwrite($fp,$description);
    fwrite($fp,"\n");
    fwrite($fp,"end");
    }
    fclose($fp);
    }
    } // end class


    Through this i am able to create a file "myfile.txt" but i am unable to retrieve the values that the user enters in the textbox.

    Please help in retrieving data or values that the users enter in the textbox to a text file.

    Thanks
    Bhawna

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem on Step 7 of Install
    By ChrisA2107 in forum Installation and Upgrade Help
    Replies: 2
    Last Post: 2007-08-20, 08:31 AM
  2. problemi step 6 di SugarSuite-Full-4.0.1h
    By lucia in forum Italiano
    Replies: 0
    Last Post: 2006-12-27, 08:50 AM
  3. Replies: 1
    Last Post: 2006-10-12, 12:07 AM
  4. 4.0.1 Installation Problem
    By clawton in forum Help
    Replies: 14
    Last Post: 2006-02-13, 04:17 PM
  5. Fatal error: Max
    By spokes2k4 in forum Help
    Replies: 3
    Last Post: 2006-01-15, 03:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •