Results 1 to 4 of 4

Thread: Adding Javascript Files into a Module's detailviewdef.php with Module Loader

  1. #1
    chadhutchins is offline Junior Member
    Join Date
    Dec 2011
    Posts
    7

    Default Adding Javascript Files into a Module's detailviewdef.php with Module Loader

    I'm working on a customization that requires installation through the module loader. I have some javascript files that need to be imported into the Contact module's detailviewdefs.php file.

    In the code, all I need to do is something like:

    PHP Code:
    $viewdefs ['Contacts'] = 
    array (
      
    'DetailView' => 
      array (
        
    'templateMeta' => 
        array (
     
        
    // ......

          
    'includes' => 
          array (
            
    => 
            array (
              
    'file' => 'custom/path/to/file/script.js',
            ),
          ),

        
    // ......

        
    ),
      ),
    ); 
    But how do I get that to be imported into the detailviewdefs when installing a module through the module loader? I'd rather not have the end-user have to figure out how to manually add that line of code.

    Thanks!

  2. #2
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Adding Javascript Files into a Module's detailviewdef.php with Module Loader

    Load the current detailviewdefs.php into an array variable. Add your change to it and write it back out via write_array_to_file() (I believe that's the funtion) and ovewrite the existing copy of the file.

    EDIT: Forgot to add you should probably do this in pre_install()
    Regards,

    Angel Magaña
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  3. #3
    chadhutchins is offline Junior Member
    Join Date
    Dec 2011
    Posts
    7

    Default Re: Adding Javascript Files into a Module's detailviewdef.php with Module Loader

    Excellent, thank you. That should do the trick. I didn't know about the pre_install() method until now.

  4. #4
    rafael.q.g@hotmail.com's Avatar
    rafael.q.g@hotmail.com is offline Sugar Community Member
    Join Date
    Jun 2011
    Location
    Florianópolis - Brazil
    Posts
    782

    Default Re: Adding Javascript Files into a Module's detailviewdef.php with Module Loader

    When you install a module is possible to move your own files to a especific sugar folder, you can do that on manifest.php of your instalation package.

    Maybe you can overwrite the file [custom]/modules/contacts/metadata/detailviewdefs.php with your own code.
    As Angel said, you can try to get the current content of this file and just include your code, this way the user do not lose his current layout.
    Rafael Queiroz Gonçalves
    Advanced OMG UML Certified Professional
    Sun Certified Enterprise Architect for the Java Platform
    Sun Certified Programmer for the Java 2 Platform
    IBM Certified Advanced Application Developer - Lotus Notes and Domino
    IBM Certified Application Developer - IBM WebSphere Portlet Factory
    Computer Science Mastering / UFSC - PPGCC

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Adding custom fields to existing modules via module loader
    By robertbmirth in forum Developer Help
    Replies: 2
    Last Post: 2010-08-13, 05:52 PM
  2. Module loader - Removing files from the upload area
    By premapix in forum Developer Help
    Replies: 0
    Last Post: 2010-05-06, 11:44 PM
  3. Adding a SubPanel to a Module's List View?
    By rickcrites in forum Developer Help
    Replies: 2
    Last Post: 2006-11-05, 01:11 PM
  4. Replies: 0
    Last Post: 2006-10-27, 10:57 PM
  5. Replies: 0
    Last Post: 2005-06-17, 09:03 PM

Tags for this Thread

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
  •