Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Add a button in Contacts module

  1. #1
    chinmayshah is offline Member
    Join Date
    Oct 2008
    Posts
    5

    Default Add a button in Contacts module

    Hi All,
    I am very new to Sugar as well as PHP. But I need to do one very small customization task for SugarCRM 5.0.
    I have to put a button next to "Merge Duplicates" in Contacts module and click on it would open a popup and call a web service.
    I tried to decipher the framework with the help of documentation, but haven't been able to find something that will help me achieve what I want.
    Can anyone list out the things I need to do for this? Or may be can point me to right documentation or help?

    It would be really helpful if anyone can reply fast as this is very urgent for me.

    Thanks & Regards,
    Chinmay

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Add a button in Contacts module

    Hi Chinmay

    Take a look at the file modoules/Leads/meadata/detailviewdefs.php
    There is a section where it is defined the button Convert Lead at $viewdefs['Leads']['DetailView']['form']['buttons']:

    PHP Code:
                    array (
                        
    'customCode' => '<input title="{$MOD.LBL_CONVERTLEAD_TITLE}" accessKey="{$MOD.LBL_CONVERTLEAD_BUTTON_KEY}" type="button" class="button" onClick="document.location=\'index.php?module=Leads&action=ConvertLead&record={$fields.id.value}\'" name="convert" value="{$MOD.LBL_CONVERTLEAD}">'
                    
    ), 
    You can do the following:
    1. Copy this code to the appropriate place in custom/modules/Contacts/metadata/detailviewdefs.php
    2. Modify the enough: labels to display and action to invoked
    3. Create the file custom/Extension/modules/Contacts/Ext/Language/<your_language>.lang.ext.php and add into it the new labels you defined for this new button
    4. Go to Admin -> Repair -> Rebuild Extension
    5. Create a script into modules/Contacts/ whose name is the name of the action you defined for the button
    6. Add into this new script the code for the webservice
    7. Redirect the page to DetailView of the current contact

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@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.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    chinmayshah is offline Member
    Join Date
    Oct 2008
    Posts
    5

    Default Re: Add a button in Contacts module

    Hi Andopes,
    I saw this file ListViewDisplay.php in contacts module. It has buildMergeDuplicatesLink() method, where the button for Merge Duplicate has been created. I need to create button right next to this button. I created a method for my button buildXYZ() but that obviously need a call from somewhere.
    What sequence would I have to follow to create and show button here?

    Regards,
    Chinmay

  4. #4
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Add a button in Contacts module

    Hi Chinmay

    If you want to render this button into ListView so you need to create a custom view.list.php for Contacts: custom/modules/Contacts/views/view.list.php.
    Then you override the listview object. It could be a class which extends the ListViewSmarty and override the method buildMergeDuplicatesLink(). This method can be a copy of the original and you can add the html code to render this new button.
    Let me know if you need additional information.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@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.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  5. #5
    chinmayshah is offline Member
    Join Date
    Oct 2008
    Posts
    5

    Default Re: Add a button in Contacts module

    I did this and created the class listView in module>custom>view.list.php which extends listViewSmarty and added my custom method in this as :
    require_once('include/ListView/ListViewSmarty.php');

    class ListView extends ListViewSmarty {
    function buildPlaceCall() {
    global $app_strings;
    $string = '<input class="button" type="button" value="Custom Button" onclick="return alert('hello world')">';
    return $string;

    }

    }

    After that I rebuilt extensions but now I am getting a blank page when I click "contacts" on the top menu.

    Can you please suggest what is wrong in this?

    Regards,
    Chinmay

  6. #6
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Add a button in Contacts module

    Hi Chinmay

    Teh blank page is due php.ini configurations. It is not set to display the error message on browser.
    You can not define the ListView class because it already exist in the system, you can define the ListViewButton instead or any other name.
    And remember you need to call the buildPlaceCall() function after instantiating this class.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@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.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  7. #7
    chinmayshah is offline Member
    Join Date
    Oct 2008
    Posts
    5

    Default Re: Add a button in Contacts module

    Thanks Andopes,
    I have managed to display a button on the contacts page by adding code in ListViewSmarty, ListViewDisplay.

    Now next challenge is to
    1. Open a popup,
    2. popuate the selected contacts phone numbers in the drop down box in the popup

    As I read in the documents and example, I think use of popupdefs may not be useful here.

    How do I do this? Any suggestion?

    Regards,
    Chinmay

  8. #8
    chinmayshah is offline Member
    Join Date
    Oct 2008
    Posts
    5

    Default Re: Add a button in Contacts module

    Hi,
    If I have to open a popup which js file do I need to edit to add functionality to button?
    (I am adding button in Contacts page and contacts.js doesn't help)

    Regards,
    Chinmay

  9. #9
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Add a button in Contacts module

    Hi Chinmay

    Your last needs are not so clear.
    Can you explain again?

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@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.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  10. #10
    azurtec is offline Senior Member
    Join Date
    Oct 2008
    Location
    Saint-Raphaël - FRANCE
    Posts
    33

    Default Re: Add a button in Contacts module

    Hi,

    I'm trying to do the same thing except that i need a new button in the Account module (trying to be as most possible upgrade safe).

    Here is what did :

    - Copy include/mvc/views/views/view.list.php in custom/modules/Accounts/view/view.list.php
    - Copy include/listview/listviewsmarty.php in custom/modules/Accounts/listviewsmarty.php
    - Copy include/listview/listviewdisplay.php in custom/modules/Accounts/listviewdisplay.php
    - Copy include/listview/listviewpagination.tpl in custom/modules/Accounts/tpls/listviewpagination.tpl

    Modifications to files copied in the custom directoy :

    - view.list.php : Changed the require_once for listviewsmarty. php to the new path.

    - listviewsmarty.php : Changed the require_once for listviewdisplay. php to the new path.

    added
    PHP Code:
            $this->ss->assign('printLink'$this->buildPrintLink()); 
    just after the buildComposeEmailLingk() call

    - listviewDisplay : Added the buildPrintLink() function in order to display my button

    PHP Code:
        function buildPrintLink() {
            global 
    $app_strings;
            
    $string '<input class="button" type="button" value="Imprimer" onclick="<script>alert(\'Test Impression\');</script>">';
            return 
    $string;
        } 
    - listviewpagination.tpl : added {$printLink} just after {$composeEmailLink} (line 52)


    Unfortunately it doesn't work. I'm sure i missed something but i can't see what for now. Maybe i don't place files in the good directory (i have doubts for the .tpl but when i modify the original one in the same way, it still doesn't work).


    If someone have an idea .... Thanks by advance.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 7
    Last Post: 2011-10-12, 01:37 AM
  2. Module Builder
    By Olavo in forum Downloads
    Replies: 418
    Last Post: 2009-02-26, 06:36 AM
  3. HOWTO - Enhance ModuleBuilder generated modules to include AJAX
    By kenneth.thorman in forum Developer Tutorials
    Replies: 10
    Last Post: 2009-01-16, 05:53 PM
  4. Cannot Add Contacts to Projects & Vice Versa
    By MatthewNoyes in forum General Discussion
    Replies: 4
    Last Post: 2008-04-17, 05:10 PM
  5. How to add a subpanel without needing a module for it ?
    By sugarWanaBe in forum Developer Help
    Replies: 2
    Last Post: 2007-08-13, 12:18 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
  •