Twisted, Long Polling, & JSONP
Mike Milano — December 30, 2011 - 10:06pm
I recently decided to use Twisted as the framework for a new project. In short, this app listens to and parses incoming events from multiple servers, as well as issues commands back to them.
Once I had Python doing its job managing the data, the next step was to expose the data in memory from the Twisted app to an existing PHP/Drupal UI. Twisted makes it pretty simple to attach an HTTP server to your app, so I did just that.
Why JSONP?
Controlling the Image Choice When Sharing with Facebook
Mike Milano — November 10, 2011 - 5:40am
Recently I had a client who wasn't happy with the images Facebook was providing as options when a user shared one of their product pages with Facebook.
You can give Facebook hints on what images you would like them to use.
Just add this code to your page for the images you would like to be in the selection:
<link rel="image_src" type="image/jpeg" href="http://example.com/images/my-image.jpg"/>
In my case, the image I defined here was the first choice that appeared on Facebook.
You can define more than one image for the available options.
Printing or Rendering a Node Field or Profile2 Field in Drupal 7
Mike Milano — October 20, 2011 - 1:17pm
When overriding a node template or user profile, you should not be drilling down the field array and printing the output unless you have a very good reason to do so. i.e. (do not do this) print $node->field_zipcode['und']['0']['value'];
The Drupal 7 field api offers us the field_view_field() function to get a renderable array of the output for a field entity.
Fixing file system permissions
Mike Milano — June 7, 2011 - 4:51pm
Have you ever shelled into a file system where a bunch of files were executable that should not be? Or maybe permissions are generally a mess?
Typically within a website file system, files should be 644 (owner read/write, group & all just read) and directories should be 755 (owner read/write/execute, group and all just read/execute).
If you don't have any special needs for individual files to be executable, or you just want to start fresh, you can use this method.
Colorbox: New Lightbox Module for Drupal 7
Mike Milano — April 10, 2011 - 10:53pm
I came across this module tonight since Lightbox2 wasn't updated to D7 yet.
It's pretty nice and I'm happy I ran into the problem that had me searching for new tools.
Adding a CCK Field to a Custom Form
Mike Milano — October 8, 2010 - 1:19am
Recently I wanted to add a CCK combo field into a custom form. Why would you need to do this? Well, my reason was to re-use a combo field with the 'add another item' functionality. Using the node form was not an option.
In this example we have a CCK combo field named "guests". Each guest has a first name, last name, and email address. The content type the guests field is in is my_event.
When adding this code to your form function, the guests field will display just as it does on the node form.
<?php // include the content file
Drupal 7 Get Image Style Path
Mike Milano — September 8, 2010 - 11:24pm
Today I was working with the new image styles (imagecache) in Drupal 7.
I created a content type with an image field and needed to embed the image style path inside custom HTML for a JQuery slideshow. That was the reason I needed to get the path vs using the theme image function.
The trick was using image_style_url().
<?php $path = image_style_url('home_rotator', $node->field_slideshow_image['und'][0]['uri']); ?>
Code Newbie vBulletin 4 / Drupal 6 Integration Project
Mike Milano — June 2, 2010 - 7:58am
This past week I've been porting a custom article system I wrote for Code Newbie to Drupal. The forums remain in vBulletin and that is the master user system.
The tricky part here is that the Code Newbie user base is in vBulletin. Surprisingly enough it wasn't that difficult utilize Drupal's user_external_login_register(). function.
Drupal 6 to 7, a first glimpse
Mike Milano — May 9, 2010 - 11:05pm
Today I finally started porting a module over to Drupal 7. I didn't read up in depth on the changes and just dove in and started learning based on the PHP errors and features that were not working.
I'm not going to go into anything too in depth here as there is good information out there already, but I took some notes and will point out some changes I had to make with the module I was working on.
Admin settings path
Spokeo a Spam Source?
Mike Milano — May 5, 2010 - 6:30pm
About a week ago my sister sent an email out to her family and friends because she was surprised to see her name and former address listed on www.spokeo.com. She advised everyone to de-list their info.
I searched for my name and found normal info that would be public record. I wasn't too alarmed by this and didn't proceed to attempt to de-list my information.
Today however, I was wondering what it took to de-list your name. More specifically, I was wondering if they request email addresses.
