2

I've added CSS to a Summary.extra.tpl file to change reports. But the CSS does not apply.

Adding the CSS by itself crashes the report (character encoding issue) so adding the {literal} tag is what I have.

{literal}
#s2id_groups {display:none;}
{/literal}

I am trying to remove the add contacts to group dropdown.

enter image description here

3

You might be able to do it with css but I might use jquery instead:

{literal}
<script type="text/javascript">
CRM.$(function($) {
  $('#s2id_groups').hide();
});
</script>
{/literal}

The problem with css might also be that you don't have a <style type="text/css"> tag around your css?

  • Thanks Demerit. Adding the style tag was needed. I haven't done much with these tpl files so great to know what is needed. – Andy Burns Jan 16 at 0:10
2

There are 3 solutions on how to achieve this

1 - Adding Javascript in tpl file as mentioned by Demerit

{literal}
<script type="text/javascript">
  CRM.$(function($) {
    $('.crm-report-form-block select[name="groups"]').closest('td').hide();
  });
</script>
{/literal}

2 - Adding a code using buildForm hook in an extension

function membershipapproval_civicrm_buildForm($formName, &$form) {
  // unset from all reports
  // Change if condition to $formName == 'CRM_Report_Form_Event/Summary'
  // if want to hide on specific event
  if (get_parent_class($form) == 'CRM_Report_Form') {
    $groupsElementIndex = CRM_Utils_Array::value('groups', $form->_elementIndex);
    if ($groupsElementIndex) {
      unset($form->_elements[$groupsElementIndex]);
    }
  }
}

3 - Adding CSS in tpl file as

{literal}
<style type="text/css">
 #s2id_groups {
  display:none;
 }
</style>
{/literal}

HTH

Pradeep

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.