Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By bickart68

Thread: How to extend JSGroupings?

  1. #1
    ewpeanutty is offline Sugar Community Member
    Join Date
    Jun 2011
    Posts
    109

    Default How to extend JSGroupings?

    Greetings,

    I have a question on jssource/JSGroupings.php

    It appears that this file controls the js files that are grouped together. The group I want to change is:
    $sugar_grp_jsolait = array(
    'include/javascript/jsclass_base.js' => 'include/javascript/sugar_grp_jsolait.js',
    'include/javascript/jsclass_async.js' => 'include/javascript/sugar_grp_jsolait.js',
    'modules/Meetings/jsclass_scheduler.js' => 'include/javascript/sugar_grp_jsolait.js',
    ),


    at the bottom of the JSGroupings.php script, there is:
    if(file_exists("custom/application/Ext/JSGroupings/jsgroups.ext.php")) {
    require("custom/application/Ext/JSGroupings/jsgroups.ext.php");
    }

    Which seems to allow one make replacements of certain scripts? I am not sure how to create an extension for the this. The script I want to replace is modules/Meetings/jsclass_sceduler.js.

    I hope I'm on the right track. I sure would appreciate a little advice on the format/syntax -- and also if I'm way off, possibly a new pointer in the right direction?

    Thanks very much,
    -e
    Last edited by ewpeanutty; 2012-10-08 at 08:23 PM.

  2. #2
    bickart68 is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    179

    Default Re: How to extend JSGroupings?

    Can you explain what you are attempting to do?

    As far as adding the additional file

    add a file into

    custom/Extension/application/Ext/JSGroupings/yourfile.php

    then do a Quick Repair and Rebuild
    asavaliya likes this.

  3. #3
    ewpeanutty is offline Sugar Community Member
    Join Date
    Jun 2011
    Posts
    109

    Default Re: How to extend JSGroupings?

    Quote Originally Posted by bickart68 View Post
    Can you explain what you are attempting to do?

    As far as adding the additional file

    add a file into

    custom/Extension/application/Ext/JSGroupings/yourfile.php

    then do a Quick Repair and Rebuild
    Hi Jeff, I am going to add a conference room module. Conference rooms would be scheduled when setting up a meeting and show free/busy times on the Scheduler along with other invitees. After I learn that part, then I will expand it to include a booking module based off Meetings to book other types of company resources.

    At least one of the scripts in question is jsclass_scheduler.js, but being in a grouping makes it just that much more convoluted to edit.

    Thank you for the information for adding a file. I am still a bit confused, how do I get my script included in a specific group?

    I thought this file "custom/application/Ext/JSGroupings/jsgroups.ext.php" is what I would need to create to modify a grouping? I don't want a new grouping, I would like to replace or override jsclass_scheduler.js that is in jsolait group.

    -e
    Last edited by ewpeanutty; 2012-10-09 at 01:42 PM.

  4. #4
    ewpeanutty is offline Sugar Community Member
    Join Date
    Jun 2011
    Posts
    109

    Default Re: How to extend JSGroupings?

    All day I looked for examples of extending jsgroupings, but I didn't find any samples. So I tried stuff out...but I'm a bit fuzzy on PHP associative array syntax (I was brought up with Perl) so is isn't very suprising to me that what I tried didn't work, but perhaps someone will say "Aha! I know what you did wrong..."

    I did create 'custom/application/Ext/JSGroupings/jsgroups.ext.php

    and I have two lines:

    //to get rid of the original association
    unset($js_groupings['modules/Meetings/jsclass_scheduler.js']);

    //to add the custom association
    $js_groupings['custom/modules/Meetings/jsclass_scheduler.js'] = array('include/javascript/sugar_grp_jsolait.js');

    -e

  5. #5
    edub is offline Sugar Community Member
    Join Date
    Jun 2008
    Posts
    56

    Default Re: How to extend JSGroupings?

    I just extended our jsgroupings, and you are close. The array you are trying to edit is actually a multi-dimensional array and that is where your problem lies. To make it easier for you to know which array needs to be modified, I recommend that you copy the contents of the JSGroupings.php to the web root temporarily and add print_r($js_groupings); to the bottom of the script and add a <pre> tag at the top of it and go to it in a browser. That will help you divine which array needs to be modified. On our instance, this is the code that you would put in the jsgroups.ext.php:
    PHP Code:
    unset($js_groupings[9]['modules/Meetings/jsclass_scheduler.js']);
    $js_groupings[9]['custom/modules/Meetings/jsclass_scheduler.js'] = 'include/javascript/sugar_grp_jsolait.js'
    Notice the [9] that I'm using there and also that I'm not using array() anywhere in that. Once you get that, refresh the page that is doing the print_r and make sure it looks right and then delete that temp file.
    Eric Wikman
    Sr Software Engineer
    Epicom

  6. #6
    ewpeanutty is offline Sugar Community Member
    Join Date
    Jun 2011
    Posts
    109

    Default Re: How to extend JSGroupings?

    Quote Originally Posted by edub View Post
    I just extended our jsgroupings, and you are close. The array you are trying to edit is actually a multi-dimensional array and that is where your problem lies. To make it easier for you to know which array needs to be modified, I recommend that you copy the contents of the JSGroupings.php to the web root temporarily and add print_r($js_groupings); to the bottom of the script and add a <pre> tag at the top of it and go to it in a browser. That will help you divine which array needs to be modified. On our instance, this is the code that you would put in the jsgroups.ext.php:
    PHP Code:
    unset($js_groupings[9]['modules/Meetings/jsclass_scheduler.js']);
    $js_groupings[9]['custom/modules/Meetings/jsclass_scheduler.js'] = 'include/javascript/sugar_grp_jsolait.js'
    Notice the [9] that I'm using there and also that I'm not using array() anywhere in that. Once you get that, refresh the page that is doing the print_r and make sure it looks right and then delete that temp file.

    This is exactly what I need! YAY! Still upgrade safe. I am adding a 'gotcha'. I am working with multiple versions of SugarCRM. One version I have calls for the extension file to be:

    custom/application/Ext/JSGroupings/jsgroups.ext.php

    and the other calls for it to be: custom/jssource/JSGroupings.php

    So after I got that straight per instance, this worked like a charm! Thank You greatly!!!

  7. #7
    sumits Guest

    Default Re: How to extend JSGroupings?

    Quote Originally Posted by ewpeanutty View Post
    This is exactly what I need! YAY! Still upgrade safe. I am adding a 'gotcha'. I am working with multiple versions of SugarCRM. One version I have calls for the extension file to be:

    custom/application/Ext/JSGroupings/jsgroups.ext.php

    and the other calls for it to be: custom/jssource/JSGroupings.php

    So after I got that straight per instance, this worked like a charm! Thank You greatly!!!
    Hi,

    I did exactly what is mentioned in the above post but it is not working for me. I want to override modules/Emails/javascript/EmailUICompose.js and modules/Emails/javascript/composeEmailTemplate.js files. I have copied them to respective custom folders (custom/modules/Emails/javascript/EmailUICompose.js and custom/modules/Emails/javascript/composeEmailTemplate.js). Created a new folder jssource under custom folder and created a new file JSGroupings.php (complete path is custom/jssource/JSGroupings.php), ran rebuild, still it is taking modules/Emails/javascript/EmailUICompose.js and modules/Emails/javascript/composeEmailTemplate.js

    I am using CE 6.4

    Thanks

  8. #8
    nanhe Guest

    Default Re: How to extend JSGroupings?

    While extending JSGroupings.php in custom/jssource/JSGroupings.php, the order of js files must be preserved otherwise there will be JS error.

    Example: I was changing modules/Emails/javascript/composeEmailTemplate.js and modules/Emails/javascript/EmailUICompose.js. When executed in the application, it was showing js error. The reason for this error is that, these two files were appended at the end of the array ($js_groupings[8]), where as the last file should be modules/Emails/javascript/complexLayout.js. Solution for this is to unset the above 3 files(see code below):

    unset($js_groupings[8]['modules/Emails/javascript/EmailUICompose.js']);
    unset($js_groupings[8]['modules/Emails/javascript/composeEmailTemplate.js']);
    unset($js_groupings[8]['modules/Emails/javascript/complexLayout.js']);
    $js_groupings[8]['custom/modules/Emails/javascript/EmailUICompose.js'] = 'include/javascript/sugar_grp_quickcomp.js';
    $js_groupings[8]['custom/modules/Emails/javascript/composeEmailTemplate.js'] = 'include/javascript/sugar_grp_quickcomp.js';
    $js_groupings[8]['modules/Emails/javascript/complexLayout.js'] = 'include/javascript/sugar_grp_quickcomp.js';

    Thanks

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Extend Class
    By Sunny_mhl10 in forum General Discussion
    Replies: 0
    Last Post: 2012-02-21, 05:57 AM
  2. Extend Class
    By jagjit in forum Developer Help
    Replies: 2
    Last Post: 2012-02-11, 01:23 AM
  3. Extend ContactFormBase
    By Francescas in forum Developer Help
    Replies: 0
    Last Post: 2011-10-19, 09:34 PM
  4. Is there a way to extend a file?
    By jim.thornton in forum Developer Help
    Replies: 2
    Last Post: 2009-07-22, 01:49 PM
  5. Extend the ACL List
    By djtremors in forum Feature Requests
    Replies: 0
    Last Post: 2006-01-23, 08:51 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
  •