Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Custom code in Subpanels?

  1. #1
    wesblake is offline Sugar Community Member
    Join Date
    Jul 2006
    Posts
    11

    Default Custom code in Subpanels?

    Hi, I actually have 2 questions about the subpanels.

    First, is there any way to call custom code for subpanels (like you can do in listviewdefs.php)?
    What I'm trying to do is add some ajax in a column. I have a new module we'll module1, setup and working with a relationship to contacts (module1_contacts table and relationship file) so I can show a contacts subpanel in my module1. This relationship table has an extra field "status" that I'd like to set from the subpanel via ajax. The ajax is written and ready (I did this before in our leads list view using listviewdefs.php custom code) but I can't see a way to actually customize a subpanel beyond columns that show (like creating ForModule1.php in contacts/subpanels)

    The second is something I'm hoping someone's run into before. I have the same exact relationships/tables set up for my module1 to leads, so I can have a leads subpanel, but the leads subpanel acts funny. When I first come to a module1 record, all the rows for the related lead records show up in the subpanel,but non of the information does (blank rows). If I click select though and select another lead to relate, the refresh of the subpanel causes all of the leads info to now show including the newly added lead. Or, if I click on one of the columns to sort by in the subpanel, all the info shows. Any ideas?

    Thanks.

  2. #2
    ronB is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    Hamburg, Germany
    Posts
    12

    Default Re: Custom code in Subpanels?

    Hi,

    sort of have the same problem. Would like to add some custom code to a field in a subpanel - is there some info about the options for the list_fields array?

    Couldn't really figure out how or if the values in this list_fields is used. Seems as if subpanels in general are generated different from list view, using the old style XTemplate engine...

    Any hints where to look for the parsed options?

  3. #3
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Custom code in Subpanels?

    Hi,
    have you tried editing subpaneldefs.php?
    Try adding to the definition of the subpanel in your module this:
    PHP Code:
    'DisplayParams' => array(
    'CustomCode' => YOUR CODE HERE
    ), 
    What do you think the cookie monster eats ?

  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: Custom code in Subpanels?

    Hi, guys.

    Remember that the correct typing is 'customCode'

    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
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Custom code in Subpanels?

    Quote Originally Posted by andopes
    Hi, guys.

    Remember that the correct typing is 'customCode'

    Cheers
    Thanks André
    What do you think the cookie monster eats ?

  6. #6
    ronB is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    Hamburg, Germany
    Posts
    12

    Default Re: Custom code in Subpanels?

    Tahnx for the answer. Sadly, it doesn't use the custom code.

    Just to have an example:

    subpanelel/default.php

    Code:
    'list_fields' => array(
    		'file_name'=>array(
    	 		'vname' => 'LBL_FILE_NAME',
    			//'name' => 'file_name',
    			//'widget_class' => 'SubPanelDetailViewLink',
    			//'type' => 'link',
    			'displayParams' => array(
    				
    				'link' => 'true',
    				'customCode' => '<a href="{$fields.file_path.value}{$fields.file_name.value}">{$fields.file_name.value}</a>',
    			),
    			
    	 		'width' => '45%',
    		),
    );
    tried some variations of the above code e.g. link => true / false setting the type - you name it. Seems to have no effect. Any ideas?
    I'm meanwhile trying to figure out how/where subpanel defs are parsed, to get a list of the options.

  7. #7
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Custom code in Subpanels?

    Ok, so..
    I was looking into this and found in \modules\Accounts\metadata\subpaneldefs.php the following:
    PHP Code:
    'linkedemails' => array(
           
    'module' => 'Emails',
           
    'subpanel_name' => 'ForUnlinkedEmailHistory',
           
    'get_subpanel_data' => 'function:get_unlinked_email_query',
           
    'generate_select'=>true,
           
    'function_parameters' => array('return_as_array'=>'true'),
    ), 
    In particular I assume that
    PHP Code:
    'get_subpanel_data' => 'function:get_unlinked_email_query' 
    is a method for retrieving data for Emails subpanels through a javascript function called get_unlinked_email_query that should be defined in <sugar-root>\include\SugarEmailAddress\SugarEmailAddress. js

    I'm not sure but maybe you can use the same syntax with a custom function.
    What do you think the cookie monster eats ?

  8. #8
    ronB is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    Hamburg, Germany
    Posts
    12

    Default Re: Custom code in Subpanels?

    Ok, I see. Thanx for the pointer DragonflyMaster. However getting the data for the subpanel is not the problem. The custom link that should be displayed is the point.

    Want to link to a special action in the target module, but the widget_class allows only Edit or Detail links. What I want to archive with the subpanel, is a link to a file, which can be opened directly from the subpanel without having to view the detail page again. Would be easy if the customCode tag was allowed...

    Looks as if the subpanel view needs to be overwriten similar to the DocumentRevisions module solution.

  9. #9
    ronB is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    Hamburg, Germany
    Posts
    12

    Default Re: Custom code in Subpanels?

    K, had time to digg a little deeper into the code. Looks as if the widget_class parameter is the point where to start at.

    Might be best practice to introduce a custom widget class for being free in options for subpanel defs. Found this in the Notes Module and adopted it for my custom modul:

    Code:
    ...
    'object_image'=>array(
    			'widget_class' => 'SubPanelIcon',
     		 	'width' => '2%',
     		 	'image2'=>'attachment',
     		 	'image2_url_field'=>'file_path'
    		),
    ...
    
    'file_path' => array(
    			'usage' => 'query_only',
    		)
    The SubPanelIcon widget class is located at include/generig/SugarWidgets/SugarWidgetSubPanelIcon.php.

    This creates a small attachment icon infront of the line, linking to the download.php with entry id and module name. Even has some more options for customization.
    Since I want some extended functionality here, I'll check if a custom widget is a good idea...
    Should be an upgrade save way too.

    Anybody any experiences with widgets?
    Last edited by ronB; 2008-04-15 at 04:23 PM.

  10. #10
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Custom code in Subpanels?

    Since you want a custom link field in a subpanel,
    what if you create a link field in the module shown in that subpanel?
    Thus you can use the customCode tag and then you'll just have to arrange the layout for the subpanel, making this new field visible in the subpanel.
    Does it make sense?
    What do you think the cookie monster eats ?

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 6
    Last Post: 2011-03-29, 10:40 AM
  2. upgraded to 4.5.1e, received "Metadata for table tracker does not exist"
    By sfgeorge in forum Installation and Upgrade Help
    Replies: 0
    Last Post: 2007-09-03, 02:24 PM
  3. Asterisk Patch 1.1.0 Crash on logon
    By skyracer in forum Help
    Replies: 6
    Last Post: 2006-07-08, 06:30 AM
  4. Replies: 7
    Last Post: 2006-06-06, 07:56 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
  •