Results 1 to 1 of 1

Thread: Extending views hierarchy

  1. #1
    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 Extending views hierarchy

    Hi people

    I just filed a new feature on Bug Tracker: 32271 - Make views more extendeable

    This feature enable any developer to extend any views and also avoiding coping all code from extended view.
    Let me explain in details.
    In the file include/MVC/View/ViewFactory.php SugarCRM decide which view file needs to be loaded.
    The sequence of choice:
    'custom/modules/'.$module.'/views/view.'.$type.'.php' (class is $module . 'View' . ucfirst($type))
    'modules/'.$module.'/views/view.'.$type.'.php' (class is $module . 'View' . ucfirst($type))
    'custom/include/MVC/View/views/view.'.$type.'.php' (class is 'View' . ucfirst($type))
    'include/MVC/View/views/view.'.$type.'.php' (class is 'View' . ucfirst($type))

    According to current strategy Sugar does try to instantiate the same class for choices 1 and 2, and also for choices 3 and 4, what obligate you to copy all code from extended view and set into new view.
    The proposed fix try to instantiate object from classes whose name is according to file to be loaded:

    custom/modules/Accounts/views/view.detail.php: view class is CustomAccountsViewDetail
    modules/Accounts/views/view.detail.php: view class is AccountsViewDetail
    custom/include/MVC/View/views/view.edit.php: view class is CustomViewEdit
    include/MVC/View/views/view.edit.php: view class is ViewEdit

    This way you can only override the method to be modified and invokes the parent method.
    I can see two benefits on this strategy:
    Override only the necessary code;
    Reduce issues when upgrading a system whose views had been customized.

    I just did the same for Controller.

    Best regards
    Last edited by andopes; 2009-07-28 at 06:39 PM.
    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.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Edit Views Should Follow List Views
    By JayL in forum Help
    Replies: 2
    Last Post: 2007-01-27, 03:41 PM
  2. Extending SugarCRM
    By jmiller56 in forum Developer Help
    Replies: 2
    Last Post: 2005-12-23, 08:12 AM
  3. Replies: 2
    Last Post: 2005-06-28, 10:18 AM
  4. Extending the calendar??
    By Fredy in forum Developer Help
    Replies: 0
    Last Post: 2004-11-24, 03:14 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
  •