Shane Graham

Shane Graham

Shane Graham is a senior Drupal developer and co-founder of Deck Fifty Design.

With 10 years experience building open source web applications, Shane has a great eye for detail. He has built hundreds of websites and knows how to speak to clients in plain English. He is proficient in Drupal and has taught college-level classes on Open Source Software. Shane enjoys creating custom Drupal modules for his clients, offering unique functionality and providing the most efficient code-centric solution. The user experience is at the forefront of all his decisions - allowing the content manager a cohesive experience while editing content and providing a natural flow for end-users. When he's not hunched over a keyboard, you can find Shane gardening in the backyard or fishing at the nearest lake.

Blog posts

Drupal 8 l() function - creating a link

The Drupal link function or l() function is a handy function you've likely used many times over the years of development. All the way back to Drupal 4.6 (my first version of Drupal) it's been a standard, something I've used so many times I don't even have to think about it. Its ability to correctly handle aliased paths, add an active class and an optional destination, makes it simple to implement yet very useful in just about any Drupal site.

Drupal Form API & Adding Entity Form Fields

It seems my love for Drupal and its Form API is always expanding, yep, kinda creepy sounding but to a web geek such as myself, it's perfectly normal to love a CMS and its API's!

In building my custom form I required an entity field which is present on user creation. Instead of duplicating the field, grabbing the current value and then saving the new value with an user_save() it's best practice to let Drupal handle the heavy lifting, since we don't want to duplicate tried and tested functionality or have to update the custom field should anything change to the entity field.

Rendering Drupal Views in code

Having a query builder like Views at your fingertips is fantastic on so many levels. I'm not going to get into my deep and semi-weird love affair with Views at this point in time, but I will show you how to programmatically display your Views display in code. This can be useful in a custom module, perhaps in a hook_node_view or maybe in one of your node or page templates.

In this example I'll add my View to my blog nodes. I'll just append my View to the bottom of the blog content. We'll want to use the views_embed_view() function to render our desired View display.