3

Now that there are icons on all the tab sets (awesome, btw) - I'd like to change the standard gear icon that appears on any custom contact field sets that are set to display as a tab. I didn't see anywhere in the interface that I could select a fa icon to use.

I know the hook_civicrm_tabset can be used if you've added a tab as part of an extension, you can just include the 'icon' => 'crm-i fa-yourchoicehere' line in your array. But I'm wondering how to apply that to an existing tab set.

3

For folks looking for a no-coding solution to this, you can use the Contact Layout Editor extension to change icons. After installing the extension, go to Administer menu » Customize Data and Screens » Contact Summary Layouts. You can click on the icon on a tab (see screenshot below) and it will bring up a menu of FontAwesome icons to choose from.

enter image description here

| improve this answer | |
  • This is very good to know - we don't use that extension currently but it looks very appealing. – RayWright Mar 13 at 16:09
  • Wow that's a lot of tabs! – Coleman Mar 13 at 16:13
1

I found there were two parts to this, first I needed to identify the current array that was setting the 'default' gear icon, then I needed to set a new one.

This page describes the basics of the tabset hook - so I started with that as a base: https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_tabset/ I built the basic hook

Then I had to figure out which nested array held the information for my custom data and I was unable to perform the code that follows without the array number (not just the custom data number). In my case, it is an 'alerts' tab. This was tricky because the number can change depending on the contact, so I couldn't just ask it to look for the 15th array, because it could be a different number per contact. I used this post's logic to search the array for the id containing my custom data.

With the array number, I was able to reset the icon part of the array

function mymodule_civicrm_tabset($tabsetName, &$tabs, $context) {
  //check if the tabset is Contact Summary Page
  if ($tabsetName == 'civicrm/contact/view') {
    // get the number of the tabset, change custom_00 to the number of your custom data fieldset
    $alertstabnum = array_search('custom_00', array_column($tabs, 'id'));
    // change the icon from the default gear icon
    $tabs[$alertstabnum]['icon'] = 'crm-i fa-flag';
  }
}

If there's an 'easier' way or something already set up in the tabset hook, I'm all ears this is just what I found to work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.