Results 1 to 4 of 4

Thread: Add custom function to existing class

  1. #1
    jacoblogic is offline Junior Member
    Join Date
    Aug 2011
    Posts
    9

    Default Add custom function to existing class

    Hi,

    I have a custom function which I want to use to extend the Contacts class of sugar.

    When i directly place it in [sugar]/modules/Contacts/Contact.php and call it through [sugar]/custom/Extension/modules/Contacts/Ext/Layoutdefs/contracts.php it works correctly however this is not upgrade safe.


    I have tried extending the class however this hasn't worked so i was wondering if there is a way I can place it in a custom contacts file or something that will make it upgrade safe?

    Cheers,
    Jacob

  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 custom function to existing class

    You can create an extended include and override the path to Contact class script:
    custom/Extension/application/Ex/Include/somescript.php

    PHP Code:
    <?PHP
    $beanFiles
    ['Contact'] = 'custom/modules/Contacts/CustomContact.php';
    ?>
    Create the script custom/modules/Contacts/CustomContact.php which should extend the default Contact 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.

  3. #3
    jacoblogic is offline Junior Member
    Join Date
    Aug 2011
    Posts
    9

    Default Re: Add custom function to existing class

    thanks for the reply andopes.

    i was unable to get this to work however our client was happy to proceed with a non upgrade safe fix.

  4. #4
    pelish8 is offline Junior Member
    Join Date
    Sep 2011
    Posts
    1

    Default Re: Add custom function to existing class

    Quote Originally Posted by andopes View Post
    You can create an extended include and override the path to Contact class script:
    custom/Extension/application/Ex/Include/somescript.php

    PHP Code:
    <?PHP
    $beanFiles
    ['Contact'] = 'custom/modules/Contacts/CustomContact.php';
    ?>
    Create the script custom/modules/Contacts/CustomContact.php which should extend the default Contact class.

    Cheers
    Can you explain this a little more?

    What is the name of class that extends Contact class?

    thanks

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Override class function
    By hzara in forum Help
    Replies: 5
    Last Post: 2012-03-08, 04:54 AM
  2. How to call another function in the same class
    By japtone in forum Developer Help
    Replies: 9
    Last Post: 2011-03-10, 05:10 AM
  3. Function sourced custom field not firing function.
    By Frances in forum Developer Help
    Replies: 4
    Last Post: 2010-11-01, 02:53 AM
  4. Replies: 4
    Last Post: 2006-11-17, 07:57 PM
  5. replacing a function in a class
    By kbrill in forum Developer Help
    Replies: 3
    Last Post: 2005-11-03, 03:33 AM

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
  •