Upcoming Events

San Francisco CiviCRM Meetup - March 2010
March 24th, 2010
Come meet others from the Bay Area who are interested in, using or developing (more...)

Campaigning Camp in Oxford, UK
March 25th, 2010
Free (with lunch and tea break included!) CiviCRM/Drupal and Plone two-track (more...)

CiviCRM Seminar - Dublin
March 25th, 2010
MTL Software Solutions are hosting a free seminar at The IBOA, Stephen St (more...)

CiviCRM User Training - Atlanta (pre NTC)
April 7th, 2010
This full-day hands-on training session is aimed at non-profit staff and (more...)

Configuring, Customizing and Extending CiviCRM - San Francisco (before DrupalCon SF)
April 18th, 2010
This hands-on 1-day training session is targeted at administrators, integrators (more...)

CiviCRM User Training - San Francisco (before DrupalCon SF)
April 18th, 2010

This full-day hands-on training session is aimed at non-profit staff and (more...)

CiviCon San Francisco 2010
April 22nd, 2010
Join us for the first ever CiviCon in San Francisco this April! CiviCon brings (more...)

CiviCRM Components

Tools for engaging your supporters...

CiviContribute


CiviEvent


CiviMail


CiviMember


CiviReport


CiviCRM 3.1 Templates, Theming, CSS Bonanza!

Not Just a Contact Database

These optional components give you more power to connect and engage your supporters.

  • civiEVENT

  • Online event registration and participant tracking.

  • civiMEMBER

  • Online signup and membership management.

  • civiMAIL

  • Personalized email blasts and newsletters.

  • civiREPORT

  • Report generation and template management.

January 25, 2010 - 09:01 — kylejaster

This is a follow up to Refactoring CiviCRM's templating system (starting with CSS). It may be helpful to read that first, although it is certainly not necessary.

We have made a lot of progress on CiviCRM 3.1's templating system, and I'm quite please to share some of the details of the work with you!

In addition to a number of minor fixes and CSS cleanup, the main contribution page template has been re-worked and we have begun implementing many of the ideas outlined in the Layout Standards page.

I've also created a new subsection in the Wiki, that deals specifically with templates & theming. I hope that this section will become a resource both for the community at large that is looking to increase their understanding of the templating system and how to leverage CSS and templating to the fullest advantage as well as to serve as a resource & guide to those committing template modifications to core who would like to follow community agreed-upon best practices. As this section is fleshed out (current entries are buttons, icons and sections elements but I am working on others) I hope to incorporate all of the Layout Standards document into each section such that layout best practices and theming best practices will be one and the same.

To elucidate the power of the new layout implementation (and as pre-cursor to additional upcoming additions to the theming section), I've created two quick css-only modifications of a dummy CiviContribute page (here is the original version):

Demo 1

CSS for Demo 1 (inserted into head of document, although could easily be in any CSS file of your choosing)

/** 
 * customizing the donation form
 * demo by kyle jaster for rayogram.com
 */

/** 
 * set all labels to be left-aligned 
 * it looks better, but it's harder to read :)
 */
#crm-container .section .label {
	text-align:left;
	}

/* quickly customize fieldsets */
#crm-container fieldset {
	background-color:#FFF;
	border:none;
	padding-left:0px;
	}

#crm-container fieldset legend {
	padding-left:0px;
	font-weight:bold;
	}
	
/* set credit card info parallel to billing info */
	
.credit_card_info-group {
	width:49%;
	float:left;
	}

/* set custom label size for credit card info */
#crm-container .billing_mode-section .label { width:110px; }
#crm-container .billing_mode-section .content { margin-left:110px; }

/* set custom label size for billing info */
#crm-container .billing_name_address-group .label { width:140px; }
#crm-container .billing_name_address-group .content { margin-left:140px; }
#crm-container .billingNameInfo-section .content {margin-left:0px;}


/**
 * move submit button to the right hand side 
 * to flow with form  
 */
#crm-submit-buttons {text-align:right;}


.email-5-section,
.premiums-group {
	border-bottom:1px solid #333;
	padding-bottom:1em;
	}

and here is Demo 2

CSS for Demo 2:

/** 
 * customizing the donation form
 * demo by kyle jaster for rayogram.com
 */

/* customize sections with padding */
#crm-container .section {
	padding:5px;
	background-color:#FAFAFA;
	}

#crm-container .email-5-section,
#crm-container .credit_card_info-section,
#crm-container .credit_card_info-section .section {
	background-color:#EDF5FA;
	}

#premiums-intro p {
	padding:5px;
	margin:0px;
	background-color:#FAFAFA;
	}

#crm-container table#premiums-listings {width:100%;}

/** 
 * set all labels to be left-aligned 
 * it looks better, but it's harder to read :)
 */
 
#crm-container .section .label {
	font-size:14px;
	} 
 
#crm-container .amount_other-section .label,
#crm-container .amount-section .label {
	float:none;
	text-align:left;
	width:100%;
	font-size:14px;
	padding-bottom:.5em;
	margin-bottom:.5em;
	}


/* quickly customize fieldsets */
#crm-container fieldset {
	background-color:#FFF;
	border:none;
	padding-left:0px;
	}

#crm-container fieldset legend {
	padding-left:0px;
	font-weight:bold;
	}

#crm-container .amount-section {
	float:left;
	width:163px;
	margin-bottom:0px;
	}
	
#crm-container .amount_other-section {
	margin-bottom:0px;
	}

#crm-container .amount_other-section .label {
	display:none;
	}
#crm-container .amount_other-section .content {
	padding-top:8em;
	}
#crm-container .amount-section .content,		
#crm-container .is_pledge-section .content {margin-left:0px;}

If you like either of these modifications, feel free to use them - or use them as a base for your own modifications - I have tried to provide thorough comments throughout the changes. Also - you might want to take a look at the Wiki's Quick Hacks page if you want test out the above CSS on your installation without modifying any files on your server ;)

Related Documents:

Wiki Section on Theming:
http://wiki.civicrm.org/confluence/display/CRMDOC/Theming+CiviCRM

Layout Standards:
http://wiki.civicrm.org/confluence/display/CRM/Layout+Standards

From Wiki's Theming Section, an implementation of Layout Standards:
http://wiki.civicrm.org/confluence/display/CRMDOC/Section+elements

*edits of 2/28/2010 - changed wiki urls to reflect change from CRMUPCOMING to CRMDOC

Comments

FYI

FYI - Most of the URL links referenced here are broken, but cut and paste of the displayed http reference works. Quick Hack is http://wiki.civicrm.org/confluence/display/CRMDOC/Quick+Hacks .

Thanks for your great work on this ...

Kudos to Kyle and the folks at rayogram.com for their awesome contributions in improving the markup, CSS, and themability of Civi!

One additional tip for folks.... starting with the upcoming 3.1 release you can define additional CSS styles to be applied to all or specific page elements (like the examples above) by adding CSS styles to the 'extra CSS' file: css/extras.css. This file is included in the downloaded codebase, but is empty by default. It is loaded for all CiviCRM pages. If you can accomplish required theming results with this approach, you can avoid the work of merging your custom CSS file / template changes with upgraded versions.

A great start

Hey Kyle,

This is a great start - it is really brilliant to see some of the ideas from the wiki being transformed into real working CiviCRM examples.

Mr personal fave is Demo 1 and I love the way there is no extraneous formatting (not at the block level nor in the text).

As well as making it easier to theme different pages, making these changes at the CSS level translates into lots of usability improvements. Looking forward to working more on this.

Michael

Love demo1

I really like how streamlined demo1 is - good work!

Style

I much prefer demo 1 in design - Good work