|
As of 1.7, you can create customized versions of the standard CiviCRM forms and pages for your site. This gives you a lot of power to modify the CiviCRM user interfaces without requiring advanced programming skills - the templates use HTML plus a fairly simple scripting languge. It also means you won't lose your customizations when you upgrade (although it is possible that changes in the core code could affect your templates - and testing after upgrades is essential). First Time Configuration
Create a Custom ScreenThese steps are for any "built-in" screen (e.g. the Contact Summary screen). Creating a custom Profile form or page are covered in the next section.
Custom Profile / Contribution / Event Registration ScreensThe process for customizing Profiles / Contribution / Event Registration is the same as above EXCEPT that you have the flexibility to create different screen "versions" for each of your configured Profile / Contribution / Event Registration Pages. The structure for contribution and event registration pages is similar to that of profile explained here. You do this by creating an extra directory layer in your custom directory tree that references the Profile's ID.
Profile ID's are listed in the Administer CiviCRM » CiviCRM Profiles table (ID column). Changing Show/Hide Default on Collapsible FieldsetsIn the words of Dave Greenberg "This is a bit tricky because the collapse vs. expand states are controlled via showBlocks and hideBlocks arrays that are passed into a jscript function by the PHP code." So I will show you how to do this using an example. If you want to make a fieldset that is by default collapsible or hidden on a CiviCRM Contact View screen, you would need to follow all the above instructions to first get the correct custom template and put it in the proper location. Let's assume you want to edit the CRM/Contact/Page/View/Tabbed.tpl screen, which is the default contact view. You would copy that into your custom template location. Then you will need to determine the name of the fieldset that you want to change the default state of. Let's say I want to collapse the "Communications Preferences" fieldset by default. Look in the file for that section, so in this case I find the line that has the following: We can see that there's a javascript onclick call which references 'commPrefs_show' and 'commPrefs'. So since this fieldset is by default showing up, we need to force the javascript to reverse it. So next you need to scroll to the bottom of this file and look for the following javascript call: The way we will fix this is to reverse the hide/show states of Communication Preferences. We will add the following two lines after And that will fix it. Our final javascript call will look like this: So for any other fieldset, you can find the show/hide names by looking for the fieldset section in the code as I demonstrated here. Just look at the <a> |
Skip to end of metadata
Go to start of metadata
Labels:

4 Comments
Hide/Show CommentsJul 18, 2008
Yashesh Bhatia
Hi.
I've added the custom_templates in the civicrm modules directory and it works fine for me.
My directory layout is
$drupal_root/sites/all/modules/civicrm/templates # original templates
$drupal_root/sites/all/modules/civicrm/custom_templates # customized templates
We choose to put it in the directory so that we could put it in the same svn
tree as the drupal_root.
Aug 05, 2008
chris burgess
In 2.1 you should be able to do custom templates per contribute / event form
See: Issue Forum mention
Sep 03, 2008
Andres Spagarino
This is great! Is there a similar setup for the css files? I am not sure if creating a new directory under the main css directory will override the existing css or do we just modify the existing files.
Sep 05, 2008
David Greenberg
A configurable method of overriding civicrm.css has been implemented for the 2.2 release. The relevant issue tracker item is: http://issues.civicrm.org/jira/browse/CRM-3346
You may be able to backport this to 2.1 (or modify the existing file for now).