Tech Tuesday: Clean URLS In CiviCRM Or How To Use Menus to Link to CiviCRM Forms

Ron asked me for a little help on a side project where he was having trouble adding a link to a CiviCRM contribution form to a primary navigation menu. This is a pretty common requirement: you want a “donate now” link in your primary nav. You are using CiviCRM for donations. You figure, “I’ll just add the civicrm contribution form url to the path field for my menu item.” Well, unfortunately you figured wrong.

Drupal will strip out some of the special characters in the civicrm contribution for url and your link will be broken!

I am sure there are other ways to handle this, and I would love to hear some suggestions. I’d also live to see path aliasing for civicrm contribution forms, or some fixes to the way the menu system and drupal path aliases handle special characters, but in the mean time, here is what i do:

I create a page node, select php for the input format and use the drupal goto function like this:

where the url for the civicrm contribution form is

Either use the menu feature of nodes (where in the node add/edit form you create your menu item) or visit admin/build/menu to add a menu item for your drupal page node.

Discover more from Gregory Heller

Subscribe now to keep reading and get access to the full archive.

Continue reading