• Development

    Creating a Link on a Product Display Node to Edit a Referenced Product

    Drupal Commerce is amazing. On a recent project I had the pleasure of working with it for the first time. I understood the link between products and product displays, but there were a few things that bothered me about the relationship. This example demonstrates a simple administrative UI modification to make it easier to edit a product display node’s referenced product. Notice I said product, not products. On this site, the requirement calls for a one-to-one relationship. Every product display will only have a single product. You’ll have to make modifications (to the block’s contextual filter (to support multiple arguments) and the PHP code (to pass back multiple product ids)) if you want to show multiple referenced products.

  • Development

    Disabling the “Read more” link if specific conditions are met

    Here’s a simple way to remove the Read more link at the module level (in Drupal 7). Sometimes this is preferred over doing it at the theme level (because maybe we don’t want the link to appear no matter what theme is being used).

  • Development

    Proximity by City or Zip Code in Drupal 6 with Location and Views

    The location module for Drupal 6 is a robust module. On most projects, it gives us 100 percent of what we need. Proximity searching based on zip code is built-in and fairly painless to setup. I’ve recently been tasked to also allow proximity searching based on City. As you might imagine, the request is very similar. Both methods require the use of latitude and longitude (decimals). The difference is that instead of querying the database for latitude and longitude based on zip code (it’s usually termed postal code in Views, Location, etc.), we’re asking for the coordinates of a city. You’ll find that many cities have multiple zip codes, each of which is a row in the location module’s zipcodes database table. In this example, I’m not giving a real honest attempt at solving this issue, but rather I just return the first coordinate that matches the city.