Putting a Paypal link into a form loaded with colorbox using Drupal 7’s FAPI

I hope my face relays the angst involved with this concept.

Here’s what I wanted out of Drupal today:

  1. Have a main menu item load in a modal popup (Colorbox) instead of directing you to a page.
  2. Specifically, load the contact form link as a popup (and maybe newsletter subscriptions as well). 

Apparently this is a huge pain in the assbutt. 

Here’s how to do it:

  • Crack open your theme.template file and add something like this in your theme_preprocess_page() with drupal_add_js in your doc ready function:



jQuery("#menu-532-1 a").attr("href","http://yoursite.com/colorbox/form/form_id?width=500&height=500&iframe=false#form_id").colorbox();



  • Thank your lucky stars you didn’t dick around with this for hours. 

Now is the trickiness - I needed to add some stuff to that popup, but the way I did it I was only loading the form itself, which means I needed to modify the form with Drupal’s awesome Forms API (FAPI).

I created a module called “helper” to store my hooks and added this:



function helper_form_contact_site_form_alter(&$form, &$form_state, $form_id){
  $form['some_text'] = array(
    '#type' => 'item',
    '#markup' => '<p>markup</p>',
  );
}



Ok, yeah, that was easy. But now I need a Paypal donation link. Typically these come as forms that you copy/pasta into your site. But you can’t hook a form into another form, that’s stupid. 

Here’s a link structure you can use in a form field’s #markup:

<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=you@whatever.com&item_name=Item%20Name%20With%20Spaces"><img src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" /></a>
This was posted 2 weeks ago. It has 0 notes.
Turns out I like mobile photography. Ive seen some shots on flickr recently that could rival some shots taken with an SLR.

Turns out I like mobile photography. Ive seen some shots on flickr recently that could rival some shots taken with an SLR.

This was posted 2 weeks ago. It has 0 notes. .
Even more hipster goodness because of the cat. The application is called Pixlr-o-matic. It has basic color filters and light filters though it still seems like it’s playing catch up to instagr.am
Something it does seem to have going for it is the ability to share photos that are actually quite large. 

Even more hipster goodness because of the cat. The application is called Pixlr-o-matic. It has basic color filters and light filters though it still seems like it’s playing catch up to instagr.am

Something it does seem to have going for it is the ability to share photos that are actually quite large. 

This was posted 2 weeks ago. It has 0 notes. .
Trying out some hipster android app.

Trying out some hipster android app.

This was posted 2 weeks ago. It has 0 notes. .

Consolidating gmail addresses

I have 3 email addresses I use for different things: (example) work@gmail home@gmail freelance@gmail.

I also happen to hate every mail client except Sparrow which I can’t use since I’m an Arch Linux guy. Most days I have 3 pinned tabs in Chrome for each email account. 

To make my life easier I consolidated them all into one account (my home@gmail address). 

Here are the steps:

  1. In the main account, head to your mail settings page and choose “Accounts & Import.” 
  2. Click “Add another email address you own” and follow the steps to add the address. Make sure to click “Treat as alias.”
  3. On the second step choose “Send through yourdomain.com SMTP servers” and set the address value to smtp.gmail.com (assuming you’re using another gapps email) or your smtp server. This will remove the “on behalf of” header that would normally get sent. 
  4. In the sub email account, head to your mail settings page and choose “Forwarding and POP/IMAP.”
  5. Set up your main account as a forwarding address. This will send an email to your main account with a link you need to click to confirm the forwarding. 
  6. Close all those darn tabs and enjoy your consolidated email world. 

Now all your emails should go into the same inbox and depending on how you set it up, you’ll either have a copy in your sub account inboxes or nothing at all. You can reply and send emails from your sub accounts within your main account by choosing an address from the dropdown on the from field in emails.

    This was posted 3 weeks ago. It has 0 notes.
    New climbing shoes. (Taken with picplz.)

    New climbing shoes. (Taken with picplz.)

    This was posted 1 month ago. Notes. .
    (Taken with picplz.)

    (Taken with picplz.)

    This was posted 1 month ago. It has 0 notes. .
    Rearranging desk (Taken with picplz.)

    Rearranging desk (Taken with picplz.)

    This was posted 1 month ago. It has 0 notes. .
    (Taken with picplz.)

Raiders of the Lost Ark 7&#8221; vinyl. This is what I call a record store find. 

    (Taken with picplz.)

    Raiders of the Lost Ark 7” vinyl. This is what I call a record store find. 

    This was posted 1 month ago. It has 0 notes. .
    This was posted 1 month ago. It has 0 notes. .