Results 1 to 8 of 8

Thread: I want to override SugarObjects

  1. #1
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default I want to override SugarObjects

    Here in Holland, we use a middlename, like "Vincent van Gogh". I'm sure you've heard of it!

    Now, I cannot override Person, because of:

    PHP Code:
        function addTemplate($module$object$template$object_name=false){
            if(
    $template == 'default')$template 'basic';
            
    $templates = array();
            
    $fields = array();
            if(empty(
    $object_name))$object_name $object;
            
    $_object_name strtolower($object_name);
            if(empty(
    $templates[$template])){
                
    $path 'include/SugarObjects/templates/' $template '/vardefs.php';
                if(
    file_exists($path)){
                    require(
    $path);
                    
    $templates[$template] = $vardefs;
                }else{
                    
    $path 'include/SugarObjects/implements/' $template '/vardefs.php';
                    if(
    file_exists($path)){
                        require(
    $path);
                        
    $templates[$template] = $vardefs;
                    }
                }
            }

            if(!empty(
    $templates[$template])){
                if(empty(
    $GLOBALS['dictionary'][$object]['fields']))$GLOBALS['dictionary'][$object]['fields'] = array();
                if(empty(
    $GLOBALS['dictionary'][$object]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array();
                if(empty(
    $GLOBALS['dictionary'][$object]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array();
                
    $GLOBALS['dictionary'][$object]['fields'] = array_merge($templates[$template]['fields'], $GLOBALS['dictionary'][$object]['fields']);
                if(!empty(
    $templates[$template]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array_merge($templates[$template]['relationships'], $GLOBALS['dictionary'][$object]['relationships']);
                if(!empty(
    $templates[$template]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array_merge($templates[$template]['indices'], $GLOBALS['dictionary'][$object]['indices']);
        
            }
            
        } 
    I would like to override these SugarObjects, just as I can with the Controller and View! I know that Sugar plans to make Beans over ridable, and I just want to make sure this is over ridable as well .
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  2. #2
    dwheeler is offline Sugar Team Member
    Join Date
    Sep 2007
    Location
    Cupertino CA
    Posts
    165

    Default Re: I want to override SugarObjects

    Although you can't override the built in fields, you should be able to create your own alternative name and field which includes a middle name field. (such as a 'custom_full_name' field) Switch the default field out for this one on all the layouts should give the same net effect as overriding one of the template fields.
    - David Wheeler
    Software Engineer

  3. #3
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: I want to override SugarObjects

    Hi dwheeler, thanks for your reply. I don't exactly understand, I have to do something in Person (or copy and modify the function that creates the full name), but where to place this custom function, and where to call it?

    - logic hooks won't do, after_retrieve is not called in ListView (why?)
    - MVC is no suitable, unless you modify every view (but then, I have to copy and modify every subpanel that Contacts has, about 10)

    Note: the solution has to be perfectly upgradeable. It's for a very big client.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  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: I want to override SugarObjects

    Hi, SugarDev.net

    You could use the logic_hook process_record, called in the data/SugarBean.php and include/ListView/ListView.php.
    This way you can inject new fields into focus when retrieving for ListView, DetailView and EditView.
    It is also implemented to void override the fill_in_additional_detail_fields and fill_in_additional_list_fields.

    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
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: I want to override SugarObjects

    Quote Originally Posted by andopes
    Hi, SugarDev.net

    You could use the logic_hook process_record, called in the data/SugarBean.php and include/ListView/ListView.php.
    This way you can inject new fields into focus when retrieving for ListView, DetailView and EditView.
    It is also implemented to void override the fill_in_additional_detail_fields and fill_in_additional_list_fields.

    Cheers
    Will take another look at it andopes, because I had tried that one, too.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  6. #6
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: I want to override SugarObjects

    Gosh, you're right andopes. Thanks!!!

    "process_record" works! The documentation in the Wiki doesn't recognize the value of this hook. I will add it.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  7. #7
    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: I want to override SugarObjects

    Hi, SugarDev.net

    Cool@
    process_record is right powerful!

    After playing SugarCRM 5.0 I started singing the song I GOT THE POWER!
    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.

  8. #8
    sourjya is offline Member
    Join Date
    Jul 2010
    Location
    Bangkok
    Posts
    18

    Thumbs up Re: I want to override SugarObjects

    Quote Originally Posted by SugarDev.net View Post
    Gosh, you're right andopes. Thanks!!!

    "process_record" works! The documentation in the Wiki doesn't recognize the value of this hook. I will add it.
    Hello SugarDev,
    Will it be possible for you to provide some code example and details on what files you modified ? Even I'm trying to achieve the same, but the only place I've been able to get the full name to display is in Detail View.

    Thanks,
    Sourjya

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Override files -version5.0.0
    By vsaranya in forum General Discussion
    Replies: 1
    Last Post: 2008-01-24, 07:59 AM
  2. Override files
    By vsaranya in forum Developer Help
    Replies: 0
    Last Post: 2008-01-24, 06:26 AM
  3. Override functionality
    By florent in forum Help
    Replies: 0
    Last Post: 2005-03-23, 04:35 PM
  4. Replies: 3
    Last Post: 2004-12-11, 06:24 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
  •