contribution forms gone wild! · 2015. 8. 25. · make it look awesome. url aliases why have urls...

32
Contribution Forms Gone Wild! Micah Lee Web Developer Electronic Frontier Foundation [email protected] @micahflee

Upload: others

Post on 26-Sep-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Contribution FormsGone Wild!

Micah Lee

Web Developer

Electronic Frontier Foundation

[email protected]

@micahflee

Page 2: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Custom Templates

● Everything in CiviCRM is rendered with a Smarty template

● Set custom templates path in: civicrm/admin/setting/path?reset=1

● You can find all the built-in templates in: sites/all/modules/civicrm/templates/CRM

● You can see what template file you need by viewing the source and search for “tpl”

Page 3: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Custom TemplatesSet the Path

Page 4: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Custom TemplatesFigure Out What Files to Edit

Page 5: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Custom TemplatesFigure Out What Files to Edit

Page 6: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Custom TemplatesCreate the Right Files

You can override template files:

templates/CRM/Contribute/Form/Contribution/Thanks.tpl

You can also have a different template for each contribution page based on ID:

templates/CRM/Contribute/Form/Contribution/41/Main.tpl

Page 7: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Custom TemplatesEdit Your Template

Page 8: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Custom TemplatesEdit Your Template

Page 9: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Custom TemplatesMake It Look Awesome

Page 10: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

URL Aliases

Why have URLs that look like this:

https://example.com/civicrm/contribute/transact?reset=1&id=41

When they can look like this?

https://example.com/donate

URL aliases (path module) work great with CiviCRM.

Page 11: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

URL Aliases

Page 12: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Hooks

hook_civicrm_buildForm( $formName, &$form )

hook_civicrm_validate( $formName, &$fields, &$files, &$form )

hook_civicrm_postProcess( $formName, &$form )

Page 13: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

civicrm_noconfirmhttps://github.com/emotive/CiviCRM-No-Confirmation

Page 14: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Javascript and CSS

Here's how you add Javascript and CSS to specific pages.

Page 15: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Javascript and CSS

Page 16: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

“Why I'm Contributing” Tweet

Page 17: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

“Why I'm Contributing” Tweet

Page 18: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”
Page 19: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

“Why I'm Contributing” Tweet

You can assign your own Smarty tokens:

$form->assign('twitter_link', $html);

Page 20: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”
Page 21: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”
Page 22: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Same Donate Page, Different Stuff

● We have separate donate and join pages

● We have separate credit card and PayPal pages

● If we want the Contribution Source to be different for a specific set of donate pages, we need to duplicate 4 pages

● We need a different Contribution Source (and other data) for each action alert thank you page

Page 23: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”
Page 24: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”
Page 25: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

First, Make a New Content Type

Page 26: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Make Your Nodes

Page 27: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

How does this magic work?

Contribution page URLs look like this:civicrm/contribute/transact?reset=1&id=$CONTRIBUTION_PAGE_ID

We add some fields:civicrm/contribute/transact?reset=1&id=$CONTRIBUTION_PAGE_ID&nid=$NODE_ID&secret=$SHARED_SECRET

And we use URL aliases to hide the secret:thanks/paypal-censorship

Page 28: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

How does this magic work?

Page 29: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

How does this magic work?

Page 30: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

How does this magic work?

Page 31: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Same Donate Page, Different Stuff

Steps to make a new custom contribution page:

● Create new custom_contribution_page drupal node with custom fields in it

● Build URL (e.g. civicrm/contribute/transact?reset=1&id=XX&nid=XX&secret=SecretValueHere

● Make a URL alias for it

To do: Implement a Drupal hook to automatically make the URL alias, so people besides me can make these

Page 32: Contribution Forms Gone Wild! · 2015. 8. 25. · Make It Look Awesome. URL Aliases Why have URLs that look like this: https: ... “Why I'm Contributing” Tweet “Why I'm Contributing”

Thanks!

Micah Lee

Web Developer

Electronic Frontier Foundation

[email protected]

@micahflee

Slides available at:

https://www.eff.org/document/contribution-pages-gone-wild