Snippet Snacks

Create a "password_reset" resource for Services

Just another quick snippet to add to the Grasmash Services archive.

This will allow you to POST an email address to /your_endpoint/user/password_reset and trigger a 'Forgot Password' email to be sent to the appropriate user.

Snippet Snack: Create Display Suite fields for Flag & Flag Count

I've decided to make a new home for the small snippets that I post periodically: Snippet Snacks. This will be small repository for useful Drupal snippets.

Here's the first one—a snippet that forms a bridge between Display Suite and Flag.

When added to a custom module, this snippet will provide Display Suite 'Flag this' and 'Flag Count' fields for each applicable Flag type.

Integrating FBOAuth with Services

Everyone loves the Services module. It allows you to easily create API endpoints for Drupal's core features, permitting you to interact with Drupal from external applications. It also very easily extended.

Among its many default resources, Services offers a user.login method that allows external applications to authenticate via Drupal. I'm going to share a quick snippet that will permit you to extend Services so that it allows your users to login via Facebook (leveraging the FBOauth module).

Start by downloading and enabling Services and Fboauth. Then, create a custom module to house your code. Your module's info file should specify services and fboauth as requirements.

Programmatically render a Drupal view with exposed filters, arguments, etc.

Embedding a view programmatically is not too difficult, but what about passing it a value for an exposed filter? This snippet gives a simple example of how to modify the View object in a more meaningful way before rendering it.

Simple jQuery script for swapping images on hover/rollover

Here's a little jQuery snippet that I use often. It lets you easily specify a 'hover-state' image for any html element with class 'rollover.' Just set the rel attribute to equal the rollover image, and the src attribute to equal the original.


jQuery(document).ready(function($) {

//rollover swap images with rel
var img_src = "";
var new_src = "";