While I've used the Previous/Next API, there is lots going on under the hood, including its on database index to search and query. I found it a little too heavy for my needs. I simply needed to get the next and previous nids when looking at a node. ...
Read more
Add images to sitemap xml hooking into xmlsitemap in Drupal
There are a few solutions for adding an image sitemap xml for easier indexing of your images in google, bing, etc., but found them be too selective or not updated when you added/edited a node. With 2 simple hooks, you can hook into xmlsitemap to add the images per url.
First, add your xml schema...
Read more
Restrict access to a node programmatically in a Drupal module
There a lots of ways of restricting access to a node, including many contributed modules. But in the spirit of hooking into Drupal and doing things another way, there is a simple hook to use where you can enter in your logic and return if access should be allowed or not.
Keep in...
Read more
Sending form data to HubSpot using Drupal
The Hubspot module handles a lot of use-cases such as embedding forms and sending data to HubSpot using webforms.
I came across a requirement that we needed to submit data to HubSpot after someone made a purchase on the site (using Drupal commerce). Using HubSpot's API, its very easy to submit form data...
Read more
Change ‘added to cart’ message for Drupal Commerce
Drupal commerce comes with a setting to display a message when adding products to your cart. This is formatted like: {product-title} added to your cart.
What if you want to add the quantity or SKU number in that description. Well, here you go with 2 simple functions.
Read more
Emailing all users that flagged a node using Rules in Drupal 7
Drupal's Flag module can be awesome in many situations. I've recently used it on a site to allow users to receive an alert when an 'out of stock' ubercart product is re-stocked and ready for purchase again. The process was pretty easy.
Part one was the 'flagging a product' part. Flag easily handles...
Read more
Creating custom tokens with Drupal Commerce order information
One thing I found lacking with Drupal Commerce was the lack of tokens with line-item level data. I wanted to send an email via Rules to the site's managers with order/product information (no billing of course). There was nothing that listed product/line items. Here is what I used to get what I...
Read more
Creating custom Drupal 7 rule events programmatically in code
With a new module comes the possibility that may require you to trigger an action based on new functionality. Using Rules, creating an event is actually very easy. And even easier is triggering that event in code so the action (and conditions) set in Rules can run.
I'm a fan of doing most logic...
Read more
Count how many nodes have a tid (taxonomy term id) in Drupal
If you need to get a count of how many nodes have a specific tid, there are a few ways of attacking the problem. One is by using views which I find overkill for this situation. You could use EntityFieldQuery which is a good option. But for this demo, I'm going to...
Read more