Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing

  1. #1
    blak3r's Avatar
    blak3r is offline Sugar Community Member
    Join Date
    Sep 2010
    Location
    Maryland
    Posts
    346

    Default Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing

    All I need to do is add a span with a particular class around the phone numbers so I can fancy them up with Click to Dial support.

    I have a /custom/modules/Contacts/metadata/subpanels/Account_subpanel_contacts.php file (this gets created when you modify the Contacts subpanel layout in studio)...

    I tried adding customCode to the phone number variable but it seems to be ignored. This custom code works in say a listview metadata file.

    Code:
      'phone_work' => 
      array (
        'name' => 'phone_work',
        'vname' => 'LBL_LIST_PHONE',
        'width' => '20%',
        'default' => true,
    	'customCode' => '<span class="phone" id="">{$phone_work}</span>&nbsp;&nbsp;',
      ),
    I'm guessing the subpanel metadata isn't being processed by XTemplate like regular listview data is. Any suggestions?


    I looked at making a custom widget but it got pretty complicated pretty quickly. As the phone one inherits from SugarWidgetFieldvarchar.php which inherits from SugarWidgetReportField... and in both files I didn't find a suitable method to overwrite to customize the output.

    NOTE: This issue has been solved. There are a few different suggestions throughout the thread. Ultimately, I went with the one eggsurplus suggested in this post: Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing Thanks for everyone's help.
    Last edited by blak3r; 2012-05-06 at 09:00 PM. Reason: Noted this thread is solved.
    Sugar 6.5 Pro, On-Site (Apache 2.2, MySQL 5.5, PHP 5.3.6)

    My Sugar Addons:
    Callinize - (formerly known as yaai) Full Featured Asterisk Integration + Mobile App(fork it here) - June 2012 POTM
    Website Visitor Tracker - powered by Google Analytics provides personalized dashlet of relevant accounts/leads/keywords for each user.
    Email To Sugar - Archive emails in any mail client by adding a BCC line.
    Task Dashlets Plus- Adds custom dashlets for: tasks assigned to me by others, delegated tasks, overdue tasks, and open tasks past start date
    Full Text Search Indexer for Sugar v6.5- OSS Solution to make your KB articles searchable today!

    www.blakerobertson.com

  2. #2
    adam.frank is offline A Prolific Poster
    Join Date
    Aug 2008
    Location
    Sydney, Australia
    Posts
    301

    Default Re: Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing

    Another option might be to use the process_record logic hook?

  3. #3
    crmwa_Joel is offline Sugar Community Member
    Join Date
    Mar 2012
    Location
    PH
    Posts
    148

    Default Re: Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing

    hi Blak3r,

    what are you trying to achieve by doing this?

    can you give a little code snipet,

    best,

  4. #4
    sjakobsson is offline Sugar Community Member
    Join Date
    Mar 2012
    Location
    New Zealand
    Posts
    25

    Default Re: Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing

    We added some custom code to deal with relationships and had to add a snippet in Metadata/accounts_contactsMetadata.php as otherwise it was not being picked up. This was due to the file already exists as processing of metadata does not give precedence to the custom/metadata version.

    Not sure if this helps at all but that was the way we got our customization to get picked up.

    Cheers,

    Sofia

  5. #5
    blak3r's Avatar
    blak3r is offline Sugar Community Member
    Join Date
    Sep 2010
    Location
    Maryland
    Posts
    346

    Default Re: Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing

    Quote Originally Posted by crmwa_Joel View Post
    hi Blak3r,

    what are you trying to achieve by doing this?

    can you give a little code snipet,

    best,
    I'm trying to surround the phone number with a span tag that has class=phone. I have some jquery code that turns any tags with this class name into clickable phone numbers.

    I provided the code snippet in my original post.
    Sugar 6.5 Pro, On-Site (Apache 2.2, MySQL 5.5, PHP 5.3.6)

    My Sugar Addons:
    Callinize - (formerly known as yaai) Full Featured Asterisk Integration + Mobile App(fork it here) - June 2012 POTM
    Website Visitor Tracker - powered by Google Analytics provides personalized dashlet of relevant accounts/leads/keywords for each user.
    Email To Sugar - Archive emails in any mail client by adding a BCC line.
    Task Dashlets Plus- Adds custom dashlets for: tasks assigned to me by others, delegated tasks, overdue tasks, and open tasks past start date
    Full Text Search Indexer for Sugar v6.5- OSS Solution to make your KB articles searchable today!

    www.blakerobertson.com

  6. #6
    blak3r's Avatar
    blak3r is offline Sugar Community Member
    Join Date
    Sep 2010
    Location
    Maryland
    Posts
    346

    Default Re: Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing

    Quote Originally Posted by sjakobsson View Post
    We added some custom code to deal with relationships and had to add a snippet in Metadata/accounts_contactsMetadata.php as otherwise it was not being picked up. This was due to the file already exists as processing of metadata does not give precedence to the custom/metadata version.

    Not sure if this helps at all but that was the way we got our customization to get picked up.

    Cheers,

    Sofia
    Thanks Sofia... I can't wrap my head around the naming conventions used by sugar. One one of my instances I have a AccountsForAccount.php and the other is Account_subpanel_contacts.php... Beh.

    Thanks for confirming it's magic if I get it working at least...
    Sugar 6.5 Pro, On-Site (Apache 2.2, MySQL 5.5, PHP 5.3.6)

    My Sugar Addons:
    Callinize - (formerly known as yaai) Full Featured Asterisk Integration + Mobile App(fork it here) - June 2012 POTM
    Website Visitor Tracker - powered by Google Analytics provides personalized dashlet of relevant accounts/leads/keywords for each user.
    Email To Sugar - Archive emails in any mail client by adding a BCC line.
    Task Dashlets Plus- Adds custom dashlets for: tasks assigned to me by others, delegated tasks, overdue tasks, and open tasks past start date
    Full Text Search Indexer for Sugar v6.5- OSS Solution to make your KB articles searchable today!

    www.blakerobertson.com

  7. #7
    sjakobsson is offline Sugar Community Member
    Join Date
    Mar 2012
    Location
    New Zealand
    Posts
    25

    Default Re: Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing

    Quote Originally Posted by blak3r View Post
    Thanks Sofia... I can't wrap my head around the naming conventions used by sugar. One one of my instances I have a AccountsForAccount.php and the other is Account_subpanel_contacts.php... Beh.

    Thanks for confirming it's magic if I get it working at least...
    Have you clicked quick repair and rebuild?

    Sofia

  8. #8
    dhavaldarji's Avatar
    dhavaldarji is offline Sugar Community Member
    Join Date
    Mar 2012
    Posts
    115

    Cool Re: Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing

    Quote Originally Posted by blak3r View Post
    All I need to do is add a span with a particular class around the phone numbers so I can fancy them up with Click to Dial support.

    I have a /custom/modules/Contacts/metadata/subpanels/Account_subpanel_contacts.php file (this gets created when you modify the Contacts subpanel layout in studio)...

    I tried adding customCode to the phone number variable but it seems to be ignored. This custom code works in say a listview metadata file.

    Code:
      'phone_work' => 
      array (
        'name' => 'phone_work',
        'vname' => 'LBL_LIST_PHONE',
        'width' => '20%',
        'default' => true,
    	'customCode' => '<span class="phone" id="">{$phone_work}</span>&nbsp;&nbsp;',
      ),
    I'm guessing the subpanel metadata isn't being processed by XTemplate like regular listview data is. Any suggestions?


    I looked at making a custom widget but it got pretty complicated pretty quickly. As the phone one inherits from SugarWidgetFieldvarchar.php which inherits from SugarWidgetReportField... and in both files I didn't find a suitable method to overwrite to customize the output.

    You can achieve this with function get_list_view_data() in the module's class file
    add the function get_list_view_data() to Contact.php if not already there.

    PHP Code:
    function get_list_view_data() {
            
    $the_array parent::get_list_view_data();
            
            
    $the_array['PHONE_WORK'] =    '<span class="phone" id="">' $the_array['PHONE_WORK'] . '</span>&nbsp;&nbsp;'      ;
            
            return 
    $the_array;
        } 
    will do the trick.

    Thanks,
    Dhaval Darji
    Last edited by dhavaldarji; 2012-05-04 at 07:59 AM.

  9. #9
    blak3r's Avatar
    blak3r is offline Sugar Community Member
    Join Date
    Sep 2010
    Location
    Maryland
    Posts
    346

    Default Re: Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing

    Quote Originally Posted by dhavaldarji View Post
    You can achieve this with function get_list_view_data() in the module's class file
    add the function get_list_view_data() to Contact.php if not already there.

    PHP Code:
    function get_list_view_data() {
            
    $the_array parent::get_list_view_data();
            
            
    $the_array['PHONE_WORK'] =    '<span class="phone" id="">' $the_array['PHONE_WORK'] . '</span>&nbsp;&nbsp;'      ;
            
            return 
    $the_array;
        } 
    will do the trick.

    Thanks,
    Dhaval Darji
    Thanks Dhaval!

    Your approach works when I added snippets into the core file at /modules/Contact/Contact.php, but when I tried to subclass it and put it in the /custom/modules/Contact/Contact.php
    Here's my complete class. Are you sure you can override Contact.php?

    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    require_once(
    'modules/Contact/Contact.php');

    class 
    ClickToDialEnabledContact extends Contact {
        
    // This function adds the "phone" class to all the contacts that show up in the subpanels on Accounts, Opportunities, etc.
        
    function get_list_view_data() { 
            
    $the_array parent::get_list_view_data(); 
            
    $the_array['PHONE_WORK'] = '<span class="phone">' $the_array['PHONE_WORK'] . '</span>';
        return 
    $the_array
        }  
    }
    Last edited by blak3r; 2012-05-04 at 04:38 PM. Reason: Changed code formatting
    Sugar 6.5 Pro, On-Site (Apache 2.2, MySQL 5.5, PHP 5.3.6)

    My Sugar Addons:
    Callinize - (formerly known as yaai) Full Featured Asterisk Integration + Mobile App(fork it here) - June 2012 POTM
    Website Visitor Tracker - powered by Google Analytics provides personalized dashlet of relevant accounts/leads/keywords for each user.
    Email To Sugar - Archive emails in any mail client by adding a BCC line.
    Task Dashlets Plus- Adds custom dashlets for: tasks assigned to me by others, delegated tasks, overdue tasks, and open tasks past start date
    Full Text Search Indexer for Sugar v6.5- OSS Solution to make your KB articles searchable today!

    www.blakerobertson.com

  10. #10
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,858

    Default Re: Adding 'customCode' to metadata for 'Account_subpanel_contacts' does nothing

    Unfortunately you can't safely override beans, yet. You can rename Contacts to Contacts_sugar.php and then have your own Contacts.php but that will get blown away on next update anyway.

    Try using the process_record logic hook. This gets fired on list view and may on subpanel view as well. If not, there is another. Then manipulate the output there.
    [SIGPIC][/SIGPIC]

    Using CE and have 2 or more users? You need SecuritySuite - Teams

Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help with customcode!
    By RodolfoJesus in forum Help
    Replies: 1
    Last Post: 2009-12-30, 02:18 PM
  2. Help with customcode!
    By RodolfoJesus in forum Help
    Replies: 4
    Last Post: 2009-12-30, 11:43 AM
  3. 'customcode' => '...'
    By tiagobahi in forum Portugese
    Replies: 9
    Last Post: 2009-04-24, 02:48 PM
  4. How to use customCode in listviewdefs
    By chemie2008 in forum Developer Help
    Replies: 2
    Last Post: 2009-03-04, 08:33 PM
  5. customCode possible? Where to put it?
    By Skeeve in forum Developer Help
    Replies: 2
    Last Post: 2008-08-25, 03:03 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
  •