3

I am currently trying to edit : sites/default/files/civicrm/templates_c/CRM/Contribute/Form/Contribution/Main.tpl

to try and alter when select box A of pricesets are chosen then hide an option in select box B, as I understand civi used a different kind of jquery select box is there anyway I can hide it so that the options do not come available as I already hide the original part but its still available

thank you

2

First - don't edit anything in the templates_c directory! These are cached pre-compiled copies of the template, and are frequently cleared out.

Second - it's not advisable to edit the templates that ship with CiviCRM directly, because you'll have to apply your changes on every upgrade.

The best practice is to install civix and create an extension, but in your case, I don't see the harm of using a template override, and more specifically a ".extra.tpl" file.

This wiki page has all the information you need. I would start by just creating a "custom templates" directory, and make sure you can successfully implement your change with a normal template override. Then remove your override and reimplement using a .extra.tpl file, and your change should be OK through most upgrades.

1

With Drupal you can easily inject some JS for specific CiviCRM URLs - this example is for an event/registration page - but this should work for all urls.

function myorg_zen_preprocess_page(&$variables, $hook) {
    if (strpos(request_path(), 'civicrm/event/register') === 0) {
      drupal_add_js(drupal_get_path('theme', 'myorg_zen') . '/js/civicrm-event-register.js');
    }
}

and then in that js file - you can add all the js you need/want to change/re-arrange the elements on that civicrm page. Things we often do:

  • show/hide custom fields based on change in the price option selected

  • replace the ugly black CiviCRM buttons with nice colorful modern sass buttons

  • style the #google_map
  • control whether the default for is_recurring on contribution pages that allow recurring contributions - is checked - or not

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.