Drupal Development Settings.php Additions

When doing frequent work for a client, you'll often need to pull the database down. There's a pretty large cost to doing this at times if you have to constantly change variables to suite development needs. Thankfully settings.php (which should never be in a repo, and thus never reach the production server), provides us a way to override variables using the code base.

Tags: 

Programatically Creating A Sales Rule Coupon Code

Had a request today for the system a Magento system to automatically create a coupon code using an existing sales rule (shopping cart rule). They wanted to control the requirements and logic in Magento's admin, but let a third party create coupon codes as required.

Tags: 

Find Nearby Nodes

I frequently need to find nodes near a location. The needs vary, but the actual search logic rarely changes. I use this function, along with the installed Location module to find nodes near a coordinate set. Note that this is Drupal 6 code. You'll need to adjust the variable handling for D7.

Joining Drupal (CCK) Fields To Other Base Tables Through Views

Working on a D6 CCK site today, so the code is slightly outdated but can likely be adapted for D7 fields quickly enough. What we had was a seperate system of key levels available to users in the system coming from a custom module. These levels were defined in a table exposed to views through the api previously. Today, we needed to create a field on a node that contained a reference to a level. There was no way to do this directly though views, as our custom base table was a loner. That left two possible options:

  1. Create a simple integer field containing the ids of the key levels as a field on the node, and create the relationship in views after 'somehow'.
  2. Create a new type of field 'something' like node reference that pointed back at our levels.

While I admin, #2 is the far stronger option for an admin controlling the system manually, that wasn't the case for us this time. The field itself is going to be updated by various events through many parts of the system. Creating a special field type just for this would have been a waste of time since the admin isn't even allowed to edit the field. So, here's how we accomplished number one.

Tags: 

Pages

Subscribe to Fragmented Thought RSS