Adding Canonical Tags To a View

The Metatags module is great. The things it does automatically across the system is really fantastic, but there's one major problem. It can't add tags to views. That's not so bad, except that paged data might really benefit from canonical links. There are multiple modules in development right now that could be used to solve this issue, but nothing I've found that is really solid. So, here is a simple hook fix you could implement from a custom module to handle the gap for now.


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.


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.



Subscribe to RSS - Drupal