CRM Open Source Business & Social CRM Software

Results 1 to 2 of 2

Thread: HOWTO - Enhance modulebuilder - Create AJAX enables modules/subpanels

  1. #1
    kenneth.thorman is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    191

    Default HOWTO - Enhance modulebuilder - Create AJAX enables modules/subpanels

    THIS IS A HACK TO THE SUGAR CODE AND IS NOT UPGRADE SAFE

    By manually editing the layoutdefs of a custom module you can achieve the same AJAX functionality as the builting Sugar modules. I was wondering why they did not implement this in Sugar straight away since it is fairly simple code to include in the layoutdefs file. Please see more information about the manual steps here (HOWTO - Enhance ModuleBuilder generated modules to include AJAX)

    Well I have attached the subversion diff/patch files for a Sugar 5.0.0e.

    But in essence

    Sugar500e\modules\ModuleBuilder\MB\MBRelationship. php

    change line 39

    from this

    var $relParams = array('name', 'relate', 'rsub', 'msub', 'label');

    to this

    var $relParams = array('name', 'relate', 'rsub', 'msub', 'label', 'quickCreateButton', 'singleSelectButton', 'multiSelectButton');

    and add the following at line 392 just after this line
    //$props['top_buttons'] = array(array('widget_class' => 'SubPanelTopSelectButton'));

    // Hack by Kenneth Thorman to allow inclusion of AJAX functionality into the custome modules.
    if ($this->relationships[$def_name]['quickCreateButton'] == "true" ||
    $this->relationships[$def_name]['singleSelectButton'] == "true" ||
    $this->relationships[$def_name]['multiSelectButton'] == "true") {

    $x = 0;
    $props['top_buttons'] = array();
    if ($this->relationships[$def_name]['quickCreateButton'] == "true") {
    $props['top_buttons'][$x] = array('widget_class' => 'SubPanelTopButtonQuickCreate');
    $x++;
    }
    if ($this->relationships[$def_name]['singleSelectButton'] == "true") {
    $props['top_buttons'][$x] = array('widget_class' => 'SubPanelTopSelectButton');
    $x++;
    }
    if ($this->relationships[$def_name]['multiSelectButton'] == "true") {
    $props['top_buttons'][$x] = array(
    'widget_class' => 'SubPanelTopSelectButton',
    'popup_module' => $this_name,
    'mode' => 'MultiSelect',
    'initial_filter_fields' => array()
    );
    $x++;
    }
    }
    // Hack by Kenneth Thorman to allow inclusion of AJAX functionality into the custome modules.



    in Sugar500e\modules\ModuleBuilder\tpls\MBRelationshi p\relationship.tpl

    add this at line 97 just before the {/if}

    <tr>
    <td colspan="2"><br/><br/>When showing {$rel.relate} as a subpanel <br/>of {$module->name} you have the following options:<br/><br/></td>
    </tr>
    <tr>
    <td class='mbLBL'>Show AJAX QuickCreate Button : </td><td><INPUT TYPE=RADIO NAME="quickCreateButton" VALUE="true" {if !empty($rel.quickCreateButton) && $rel.quickCreateButton == "true"}checked{/if}>true <INPUT TYPE=RADIO NAME="quickCreateButton" VALUE="false" {if empty($rel.quickCreateButton) || $rel.quickCreateButton == "false"}checked{/if}>false </td>
    </tr>
    <tr>
    <td class='mbLBL'>Show AJAX SingleSelect Button : </td><td><INPUT TYPE=RADIO NAME="singleSelectButton" VALUE="true" {if !empty($rel.singleSelectButton) && $rel.singleSelectButton == "true"}checked{/if}>true <INPUT TYPE=RADIO NAME="singleSelectButton" VALUE="false" {if empty($rel.singleSelectButton) || $rel.singleSelectButton == "false"}checked{/if}>false </td>
    </tr>
    <tr>
    <td class='mbLBL'>Show AJAX MultiSelect Button : </td><td><INPUT TYPE=RADIO NAME="multiSelectButton" VALUE="true" {if !empty($rel.multiSelectButton) && $rel.multiSelectButton == "true"}checked{/if}>true <INPUT TYPE=RADIO NAME="multiSelectButton" VALUE="false" {if empty($rel.multiSelectButton) || $rel.multiSelectButton == "false"}checked{/if}>false </td>
    </tr>
    Attached Files Attached Files
    Last edited by kenneth.thorman; 2008-06-09 at 08:13 PM.

  2. #2
    kenneth.thorman is offline Sugar Community Member
    Join Date
    Oct 2007
    Posts
    191

    Default Re: HOWTO - Enhance modulebuilder - Create AJAX enables modules/subpanels

    The code in the template file is not nice looking, but I had problems getting the buttons to properly reflect the correct values.

    I had to build a rather large module and was getting tired of manually adding this lines of code all the time so figured it was time to look at how to put this in the module builder. I was thinkging about implementing GUI support for all the different things you can do in the defs files in the module builder but will wait and see what version 5.1 brings to the table in final form.
    Last edited by kenneth.thorman; 2008-06-09 at 08:17 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. HOWTO - Enhance ModuleBuilder generated modules to include AJAX
    By kenneth.thorman in forum Developer Tutorials
    Replies: 10
    Last Post: 2009-01-16, 06:53 PM
  2. Subpanel: Create new AJAX without hidding existing rows
    By kenneth.thorman in forum Developer Help
    Replies: 4
    Last Post: 2008-06-10, 08:44 AM
  3. Howto create scheduler on module installation
    By mscifo in forum Developer Help
    Replies: 0
    Last Post: 2007-12-27, 11:38 PM
  4. Howto create a custom dropdown list?
    By andreasw in forum Help
    Replies: 6
    Last Post: 2006-08-15, 02:14 PM
  5. Replies: 4
    Last Post: 2006-05-10, 02:59 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
  •