Apr 09 2019
Apr 09
[embedded content]

Here is a recording of a presentation I did at a local JamStack Boston meetup. This provides a good high level overview of how to use Gatsby with Drupal as a backend content source.

Some resources from the presentation:

Dec 04 2018
Dec 04

The Drupal 8 Rabbit Hole Module allows you to control what happens when someone views an entity page. Before you ask why this might be important, let me clarify, it's not a layout tool. It's a simple module that allows you to easily redirect or prevent users from viewing specific types on entities on your site. If you have content types or other entities that you are using to either build out a view or other area of your site, but don't want users to access the original page for this content type or entity, this is the module for you. If you read this entire description and are still confused, I promise it's very simple. Check out the video to find out how it might be useful for you on a future project.

Nov 20 2018
Nov 20

By shane

Tue, 2018-11-20 00:27


Video of Drupal 8 FlexSlider Module - Daily Dose of Drupal Episode 220

Daily Dose of Drupal Episode #220

Share with Others

The Drupal 8 Flex Slider Module allows you to use the Flex Slider library to build out slideshows on your Drupal website. This video covers how to get Flexslider to integrate with Drupal views as well as Drupal fields.

Nov 19 2018
Nov 19

Video of Drupal 8 Configuration Read-only Module - Daily Dose of Drupal Episode 219

The Drupal 8 Configuration Read-only module allows you to lock down some of your environments to prevent users from making configuration changes. This lets you use the Drupal 8 configuration management system to push up all your changes, while preventing you from changing any settings, content types, views, or any other configuration on your production website.

Nov 13 2018
Nov 13

The Drupal 8 Editor Advanced Link Module allows you to specify additional attributes when creating links in your content. This makes it easy to add a CSS class, an ID, open the link in a new window, or even specify a rel="nofollow" tag. The module is very easy to use, but there is a small trick to getting it set up. Watch the video to see how it's done and start customizing your links in no time!

Nov 12 2018
Nov 12

The Drupal 8 Editor File Upload Module is a great module for allowing your content editors to upload files directly in your website content. If you have ever needed to upload a file, and then include a link to that file, then the Editor File Upload module will be useful. Rather than having to upload the file manually using FTP or through another module, then having to go back to create a link in your content to that file, this module lets you do it all in one step. This saves you (or the other content editors on your site) a lot of time.

Nov 10 2018
Nov 10

The Drupal 8 Image Widget Crop Module is a handy module for allowing your content editors on your website to crop images after they upload them. Have you ever uploaded an image on a website and had it automatically crop the image for you in a way that just looks wrong? This module solves that problem!

Nov 09 2018
Nov 09

Video of Drupal 8 Contact Storage Export Module - Daily Dose of Drupal Episode 215

In this episode, we cover the Drupal 8 Contact Storage Export Module. This episode covers a module that adds additional functionality to the Contact Storage Module (which we covered in episode 213). This module allows you to export your contact form submissions to a CSV file. It's a simple module that serves a very specific purpose. If you need to export your contact form submissions, this is how you do it!

Check out the Code Karate Patreon page

Oct 31 2018
Oct 31

In this episode, we cover the Drupal 8 Linkit Module. This module extends the link functionality of your Drupal 8 WYSIWYG editor (like CKeditor) to make it easier to link to other pages on your website. Rather than having to go find a page on your website you would like to link to, copy the URL, and paste it in the link field, this module allows you to do it in one step!

Check out the Code Karate Patreon page

Oct 30 2018
Oct 30

In this episode, we cover the Drupal 8 Contact Storage Module. This module extends the Drupal 8 core contact module by saving the contact entries in the database. This makes it easy to go back and view, edit, or delete any of the contact form submissions on your Drupal 8 site. It's a handy little module that can save you from needing to install a more fully featured form module (like Webform or Entity Forms).

Check out the Code Karate Patreon page

Oct 29 2018
Oct 29

In this episode, we will cover five different ways to download and install modules in Drupal 8. Yes, that’s right, FIVE different ways! If you are just getting started with Drupal or are transitioning from Drupal 7 to Drupal 8, this is a great place to start. Once you understand all the ways to download and install modules, you can make the decision on which option works best for you.

Check out the Code Karate Patreon page

Oct 28 2018
Oct 28

Lando is what the cool kids are using for their local development environments these days. In this episode, I give you a quick introduction to Lando and show you how it can be used to create a Drupal 8 site in less than a minute. I also show you how you can integrate Lando into your workflow if you are hosting your websites on Pantheon.

Are you using or have you tried using Lando yet? What are your thoughts?

Check out the Code Karate Patreon page

Oct 25 2018
Oct 25

Hello everyone and welcome to another Daily Dose of Drupal, today we are on episode #210. Wow, it's been over three years since I last posted a video, and a lot of things have changed over the last three years, but a lot of things have stayed the same too... after all, you can still follow me on Twitter at smthomas3.

So I'm going to keep this episode short and sweet, but I do have some big news. I'm going to start posting Drupal 8 content, a lot of it. I've been stuck in the Drupal 7 world for a long time, and I just really haven't got the time to put out any new Drupal 8 content. But that's all going to change. So I am going to start posting Drupal 8 content on an almost daily basis going forward. I'm really going to keep doing it until I run out of things to say, and I do have a tendency to ramble on... so we might be here awhile.

So the next big announcement is that everything on CodeKarate.com going forward, and all the stuff I did in the past is all going to be free. Yep, you heard it here first! Just head on over to CodeKarate.com, enter your email, and you will get access to all my ebooks, all the stuff you used to have to pay for. Really I just got to the point where I didn't want to have to save my "best stuff" behind a paywall. I thought it would be better to just post all my best stuff on YouTube and on my website for free. Now what I am asking is if you do find value in what I am posting, head on over to my Patreon page. If you can afford a few dollars a month, it's going to help me to keep posting more and more of this Drupal 8 content. We all know when you get started with Drupal, it can be a little bit intimidating, it can be a lot to learn.

The goal here with Code Karate and the Daily Dose of Drupal is to put out as much Drupal 8 content as possible and try to organize it in a way that someone just getting started with Drupal can understand. So the goal is to keep it free, if you do find value please head over to the Patreon page and maybe just throw in a couple dollars a month, that would be awesome. Also, if you do that, there is a chance you can get a sticker, you can get your own Code Karate t-shirt, and some other cool things for helping me out that you can get by heading over to the Patreon page.

So with this first video, I wanted to mention those few things, but I also wanted to get the discussion going. What are you struggling with in Drupal 8. What's the content or videos that you want to see produced. The goal here is that I'm going to start with doing what I have done a lot in the past which is post videos on Modules and how to use them. But I also want to get into more in-depth topics such as Module development, site building, configuration management, building out Drupal API's to use with either Javascript frameworks or mobile apps, theme building, theme development, any of those types of difficult and in-depth concepts I want to get into that first. I am going to start with the modules and then lead into some of that.

But if you have things with you are struggling with or you would like to see, let me know and hopefuly I can get some feedback from everyone then prioritize what the community in general is really having trouble with. Thanks for checking out Code Karate, thanks for watching this video, and go ahead and buckle your seatbelt because Code Karate is back. We'll see you next time.

Jul 16 2015
Jul 16

Have you ever wanted to create a page on your Drupal 7 website and send it over to a friend or group of people… but you don’t want the general public to see it? You could always set it up so they just log in, but that’s an extra step and not all of the people you want to send this to have user accounts on your site.

If this sounds like you then the Token Content Access Module is just what you need. The Token Content Access Module makes it easy to hide a page and require a unique key to be added to the URL to gain access. This means you can create content, hide it from those pesky anonymous users, and drop that hidden link directly into an email campaign to ensure only subscribers will see the page.

Configuration on this module is simple. Just turn the module on, edit the content type settings, and finally edit the page. That’s really all there is to it.

Jun 24 2015
Jun 24

If you are just getting started with Drupal and are looking for some help on learning Drupal 7. You have come to the right place.

In this simple Drupal tutorial, I will highlight some resources for getting started, provide you some Drupal basics, and then if you are interested, you can sign up for Code Karate's 30 Day Drupal Email series (using the form at the bottom of this post). The email series breaks the entire Drupal 7 learning process into manageable chunks spread out over 30 days. In fact, the Drupal tutorial below is just a simplified version of what you will get in your inbox.

Drupal introduction

First, you might be wondering... "what is Drupal and why should I use it?"

Well, in it's simplest terms, Drupal is an open source content management system (CMS) that can be used to build all different types of websites from simple to very complex. Drupal allows you to create a website and manage all your content, media (images & video), users, and so much more. Drupal is much more than this, but hopefully that gets you pointed in the right direction. Drupal will help you build awesome and extremely flexible websites... that's the best simple definition I can think of.

Now you are ready to learn about some available Drupal learning resources. The link below will take you to a link that discusses some of the various ways to learn Drupal.

Best Way to Learn Drupal

If you are ready to get started right now. Read the following two sections to learn how to get Drupal installed and how to start managing your content in Drupal. If you get stuck or need additional help, don't hesitate to contact me.

Installing Drupal


  • Learn about the different methods for installing a Drupal 7 website
  • Learn how to get a Drupal website installed

There are many different ways to install Drupal. These different ways depend on how you want to develop your site and what type of computer you are using. The first question you need to ask yourself is if you want to develop your Drupal website locally (directly on your computer) or if you want to use a third-party service for developing your Drupal site. You will learn about each of these different options.

Installing Locally

The most common way to get started is to install your first Drupal 7 website directly on your computer. In order to do that, you will need to install some programs to get your own personal web server set up. The setup varies depending on what type of operating system you are using. In the following sections, you will find resources for getting Drupal installed locally for a variety of different operating system.

Installing on Linux

You might wonder why Linux is the first on this list. Well.. perhaps I am a little biased. Either way, below you will find a link that will walk you through how to get a local development environment set up on an Ubuntu Linux operating system. Other flavors of Linux are similar, but may vary a little.

Installing using Acquia Dev Desktop

If you are running Windows or Mac and want a more streamlined option, I would recommend using Acquia Dev Desktop. It provides a simple and seamless experience.

Installing on Mac

Macs are also popular options for developing with Drupal. If you have ever attended a DrupalCon, Drupal Camp, or other Drupal-related event, you will undoubtedly have seen an abundance of Apple logos in every session. Installing Drupal on a Mac is pretty straightforward, just follow the videos below to get your own MAMP server set up. MAMP stands for Mac (the operating system), Apache (the web server), MySQL (the database), and PHP (the programming language).

Installing on Windows

If you are using windows, you will want to install either WAMP (Windows, Apache, MySQL, PHP), or XAMPP. You will find links below for both options.

Installing using Vagrant

Vagrant is a tool that allows you to build an easy to reproduce development environment. This means you will have a consistent development environment that you can rebuild, reconfigure, and essentially destroy as needed. It’s a tool that I along with many other seasoned Drupal developers use. If you are just getting started with Drupal, and you are not a well versed server administrator, you might want to come back to this later. If you do want to check it out, the link below can start pointing you in the right direction.

Installing on an external platform

There are other third party platforms you can use to develop your Drupal website. Some of these are built directly for developing Drupal websites, and others are built to support a variety of other platforms, but still allow you to develop a Drupal site.

Here are some services that provide development environments specifically tuned for Drupal. Feel free to sign up to either of these for free to try them out. They have pretty straight forward documentation on how to create your first Drupal site.

Here are some more general Drupal hosting services that CAN serve as a development environment. I would recommend using the other above options if possible to develop your Drupal site, and keep the options below for when you are ready to launch your site live.

Wrapping up the Install

As you can see there are many options to install Drupal. Unfortunately there is no one right way. It all depends on what you are looking for. If you are in a bind and don’t know what to do, I would suggest trying Acquia Dev Desktop first, and going from there.

Managing Content


  • Learn how to add, edit, and delete content on your Drupal site
  • Learn how to use the content administration page

First, look through the following two articles from Drupal.org:

Now, complete the following steps on your own to try out what you just learned:

  • Create your first few pieces of content on your Drupal site. These could be pages or articles but make sure you have at least one article.
  • Make sure you can find, filter, and edit the content from the Content Administration page
  • View your homepage to see a list of articles you have created. Notice that if you click on the title of the article you get to the full node page. From this page, you will see tabs at the top for viewing and editing the individual node.

Content Management Summary

You have now learned how to add, edit and delete content from your site. Make sure to spend some time trying out the available configuration options when creating content to get a feel for what they all do.

Getting Started with Drupal Summary

You now know how to install Drupal and how to manage content inside of Drupal, but you still have a lot to learn. These first few steps are only the beginning. If you want to continue learning more about Drupal, you can enter your email below to receive an email a day teaching you more about Drupal for the next 30 days. If you want to continue learning right now and don't want to wait 30 days, take a look at Code Karate's Learn Drupal in 30 days eBook.

Good luck on your Drupal journey!

Jun 19 2015
Jun 19

Drush... what a wonderful web you weave. My guess is you have probably heard about this mysterious thing known as "Drush" and are looking to find out:

  1. What exactly is Drush?
  2. Is Drush something that will be useful for me?

The first one is an easy one. Drush is short for Drupal Shell and is a command line tool that makes interacting with your Drupal website a breeze.

The second question is also easy, but first I have a question for you. Do you use Drupal? If the answer is yes... then Drush will probably be useful for you.

Drush: An Introduction

You might be thinking to yourself about now... "but I don't spend hours of my day behind a command prompt". In fact, you might be a little nervous about even having to open a command line window. Don't worry... we will try to take it slow.

I'm convinced that if you do even a modest amount of Drupal development, spending just one hour learning how to use the command line and Drush commands will save you countless hours of time. In the next few sections, I am going to show you how Drush can be used to automate and simplify a lot of common Drupal administrative tasks.

Getting used to the command line

If the command line scares you... don't worry, you are not alone. At one point many years ago I was thinking the same thing... "why can't there just be a nice GUI for this?" If you spend a little time learning though, you will quickly find out that it's not as bad as it seems and it can save you a lot of time.

If you are not familiar at all with the command line, below you will find a quick tutorial that will help you get started. If you are already familiar with using the command line, you can skip this section.

Special Note for Windows Users: Sometimes it's tough to be a Windows developer... This is also true if you want the best experience using Drush. You "technically" don't need to install any additional programs to get started, but I would recommend installing Msysgit and getting it to work with Drush. This tool will provide a much better and more powerful command line experience. Msysgit will allow you to use a Bash shell (just like your Linux and Mac friends).

Opening up the terminal

It's now time to open up the terminal. If you are using Windows, open up your shiny new Msysgit program. If you are using Mac OSX, open up your Finder, select Applications, then Utilities, and find Terminal.

Oh... If you are using a flavor of Linux (like I am as I write this)... wait who am I kidding. You already know how to use the Terminal... go ahead and skip this section!

Some basic commands

Don't be intimidated by the contents of the terminal window (or the lack thereof). Simply get started by typing in a simple command. Go ahead and type:


Then hit Enter.

You should now see a list of the files in the current directory. This is no different than browsing your files on your file system. Now try:


This command stands for "print working directory" and will print out in the terminal your current location. The next step is navigating, you can do this using the cd command. Go ahead and run the following command:

cd ..

This tells your terminal to "change directory". The .. tells the terminal to go up one folder. You can use the pwd command to see your current location.

If you want to go back into the folder you just navigated out of, try this:

cd [folder-name]

Replace [folder-name] with the name of the folder you want to navigate into. Note: Once you start typing the folder name, you can hit tab to auto-complete the name for you. You will use the tab key often when you are using the Terminal to save you time.

Those are the basics, but there is a lot more to learn. Here are some other commands you might want to try out.

Command What it does cd This command on its own will return you to your home folder (where you started when you opened up the Terminal) touch [file-name] Create a new empty file called [file-name]. Example: touch test.txt mkdir [folder-name] Create a new folder. Example: mkdir myfolder cp [file-name] [new-file] Create a copy of [file-name] and call it [new-file]. Example: cp test.txt backup.txt mv [file] [new-location] Moves a file to a new location. Example: mv backup.txt ../ This will move backup.txt up one folder level. rm [file-name] Deletes the file [file-name]. Example: rm test.txt

Drush: Getting things Installed

The first step is to get Drush installed. Installing Drush is not an overly complicated process, but because it varies depending on the operating system your website runs on, and if you are running the site locally or on a remote server, I won’t go through all of the installation possibilities here.

There is a page on Drupal.org that provides information depending on the type of platform you are installing Drush on. Typically you need to install Drush on the server that is hosting your Drupal website (you can get around this with something called Drush aliases, however, we won’t be covering that topic). For the installation instructions, go to https://drupal.org/node/1791676.

Drush: Downloading and Installing Modules

We are now ready to begin installing some Drupal modules and themes on our new Drupal website. I am going to start with one simple example. Downloading and installing the module_filter module.

Drush Command What does it do? drush dl [project-name] Downloads a Drupal module or theme. The name can be grabbed from the drupal.org project name. For example in https://drupal.org/project/module_filter the project name is module_filter drush en [module-name] Installs a Drupal module. Keep in mind when you download a Drupal module, it may contain multiple modules. You can get the correct module name from the output of the drush dl command.

The first step is to download the module_filter module using the drush dl command:

This command will tell you where the module was downloaded (in this case sites/all/modules/module_filter) and if there are multiple modules that can be enabled/installed.

Now we install/enable the module using the drush en command.

You can also use the drush en command to download and enable multiple modules at a time. Just put a space between each module name when running the command.

Drush: Disabling and uninstalling Modules

There may come a time where you need to disable a Drupal module. If this is the case, you can do so with the drush dis command. You can then uninstall a disabled module with the drush pm-uninstall command.

Drush Command What does it do? drush dis [module-name] Disables a Drupal module. drush pm-uninstall [module-name] Uninstalls a Drupal module.

If you were launching your website and you no longer needed the views_ui module, you can disable the module using drush dis views_ui.

A Drupal module can be disabled, but that does not necessarily mean it is uninstalled. A Drupal module may create additional database tables in your Drupal database or add additional variables to your Drupal variables database table. If you disable the module, those database tables and variables will not be deleted. This means you are able to enable the module later without losing any of your module settings.

The drush pm-uninstall command will completely uninstall your module removing any database tables and variables that the module has stored.

Here we run the drush pm-uninstall views_ui command to uninstall the Views UI module that we previously disabled.

Drush: Running cron and clearing cache

Now you will learn how to use drush to run cron and clear the cache on your Drupal site.

Drush Command What does it do? drush cron Runs Drupal cron process. drush cc Clear the Drupal cache. drush cc all Clear all of the available Drupal caches.

You can manually run the Drupal cron process using Drush by running the drush cron command.

You can clear the Drupal cache using the drush cc command. After running this command, Drush will provide you an option to select which cache you want to clear. In this example we select 1 to clear all of the available Drupal caches.

You can also specify which Drupal cache to clear directly in the drush cc command. In this example we run drush cc all too clear all of the Drupal caches without the extra prompt to choose the Drupal cache to clear.

Additional Drush Commands

Here are some additional Drush commands you might want to try out:

Drush Command What does it do? drush archive-backup Backs up the code, files, and database of a Drupal website. drush archive-restore [backup-path] Restores a Drupal website to a previously backed up state. drush up Updates the modules, themes, and core Drupal code on your Drupal website. This command will also perform any necessary database updates.

Drush Wrap-up

There is a lot more you can do with Drush. You can always get a list of commands by running drush help. You can also use the helpful website drushcommands.com. If you want a helpful Drush cheatsheet, enter your email in the box at the bottom of this page and I will send you mine! I will also send you some additional Drush commands and getting started ideas.

Jun 14 2015
Jun 14

Are you testing your site? Until recently, we weren’t and it was costing us. Every element on your website should have a meaning and if you aren’t testing it against something else how can you be sure that you are maximizing your results!

Welcome, Optimizely. Optimizely is an A/B testing tool that allows you to modify the HTML and CSS of your website to test different website elements. The configuration for this service is limitless. After you configure an Optimizely experiment you then get to look at the results and determine how each element worked best on your site. Remember, knowledge is power and Optimizely sure give you a lot of knowledge.

How does this relate to Drupal? Well, if you use the Optimizely Drupal module you are able to specify which pages you want the Optimizely Javascript to load on. By default, optimizely will load the Javascript file on every page. The problem with that is your experiment most likely is only on one page. Loading a Javascript file on pages without an experiment running is wasteful and slows down page load time.

Jun 07 2015
Jun 07

What if you had to go build a Drupal site on a remote island without WiFI? Yes that's right, no internet connection at all? What modules would you bring with you?

For some random reason, I posed this question to myself and came up with these 4 modules. Because I believe these modules can be used to build a multitude of complex Drupal sites, I think of these modules as the "Ultimate Site Builders Toolkit". Become an expert in these modules and you will be able to build some wicked awesome and complex Drupal 7 sites.

Module #1: Views

The Views module was, of course, my first choice. How can it not be? I use this module in every Drupal 7 website I build. Most people know that the Views module is great for creating lists of content. However, not everyone knows the intricacies and complexities of views. Once you start learning about relationships, contextual filters, and aggregation, it opens up a whole new world of possibilities.

If you are going to build a complex Drupal website on a remote island... you are going to want to take Views with you.

Module #2: Panels

This one will be the most controversial. After all, everyone has their site building layout tool of choice. For some, it might be Display Suite, Context, or some other Drupal module... but for me, it's Panels hands down, without a doubt. I know it can be a little heavy-handed at times, but it's packed with a plethora of features that make any site builders worst layout nightmare a breeze.

If you are just getting started with Panels it can seem a little intimidating at first. There are so many things you can do with the module. Once you master the basics and start understanding contexts, relationships, variants, and visibility rules, the options really start to open up. If you know what these are and how they are used, you can master almost any layout with ease.

I am packing the Panels module in my suitcase when I head for that remote island. Quick question... does this remote island have a nice beach? I sure hope so...

Module #3: Rules

When you say to yourself, "when this happens, then I want to do this" that is usually a solid foundation for a rule. Rules can do so much that sometimes the true test is to learn when to not use them. I can't tell you how many developers have contacted me asking me to help them get the rules module to do something that could easily be accomplished with views, panels, and entity references.

If you do master Drupal rules, you can accomplish some pretty awesome things.

Remote island... Check. Rules module... Check. What to do when my laptop battery runs out.... Unknown.

Module #4: Entity Reference

Used correctly, the entity reference module allows you to build complex and interconnected data structures. This one module helps turn Drupal into a content and data modeling tool. You might be wondering what is so great about relating content with entity reference? Well, content doesn't live on an island (even though I am on one in this figurative thought exercise). This means content is connected to other entities (nodes, users, etc) on your site in sometimes complex ways. The Entity Reference module makes this possible.

The Ultimate Site Builders Toolkit Summary

Arming yourself with great working knowledge of these modules will make you absolutely lethal when it comes to completing complex website requirements. Did I mention you can do this without having to write a single line of PHP code?

How do you rate yourself on knowledge with these modules? If you want to become a better Drupal site builder (without having to write code), then leveling up your skills with these modules is one of the best ways to spend your time.

It's your turn to take the #IslandOfDrupal Test

So now I pose the question to you, if you had to go build a Drupal site on a remote island without WiFI, what modules would you take with you?

Go ahead and take the #IslandOfDrupal test yourself and post your answer in the comments below (and try to keep the number of modules below 5)... This should be interesting!

Also, please share this post with others in the Drupal world.

May 30 2015
May 30

Awhile back I posted a video on setting up a Drupal sub-theme. If you want, you can check out that video here. I think that the video does an alright job of explaining the steps you have to take to get a sub-theme to work properly. I don't however think it provides enough of the setting up a sub-theme "meat" needed to begin. The saying goes, the devil is in the details. Personally, I never liked that quote, but it is fitting here. Anyway, if you're looking to get a full in-depth guide to setting up a Drupal sub-theme, you, my friend, just need to keep scrolling.

Let's begin.

What is a sub-theme anyway?

This seems like the appropriate place to start. Drupal has two types of themes; you have a base theme and a sub-theme. A base theme (Zen for example) provides basic theme design and functionality. The work has already been done for you. Cha-ching! A sub-theme provides all the unique design and functionality. A sub-theme where you get to build the exact website of your dreams.

If you're still confused, try thinking of it this way. Let's assume a base theme is the basic vanilla ice cream cone. A plain vanilla cone is still a cone. You could eat it up and leave happy, but what if you wanted to add some strawberry syrup? Adding the strawberry syrup is like adding the custom design to your site. So instead of having to create the entire cone (remember the vanilla was already provided) you just have to add the strawberry syrup or whatever you want to build the ice cream cone you desire. Drupal base themes and sub-themes work exactly like this. Using a base theme will provide you a lot of the design and functionality you need and then you can use a sub-theme to design the site exactly how you see fit.

Are all base themes created equal?

This is kind of a hot topic with designers in the Drupal community. In my opinion, the answer is nope. Every designer has their personal preferences to which base theme to use. Some of the most popular base themes are Zen, Omega, Fusion, and Basic. Personally, I use Zen. Any theme can be made into a sub-theme. This makes choosing a base theme endless. If you're just getting started with designing in Drupal, it is best to spend some time working with a variety of theme to find which theme works best for your coding style. Here a few reasons why Zen works for me.

  • Widely supported and used (over 1.5 million downloads)
  • Responsive out of the box
  • Supports SASS
  • Follows a concise file structure
  • Easily customizable

Downloading and enabling Zen

Let's start with getting Drupal Zen installed. You will want to go here and download the newest recommended release of Zen. To download, simply click on the either the .zip folder or .tar.gz folder. Once the download is complete go ahead and extract (unzip) the folder.

Note: I'm assuming you're using Drupal 7. If you're using a different version of Drupal things aren't going to work exactly the same.

Next, we need to move the folder onto our site. If you don't currently have a site setup, you can follow along with this video on setting up a site using Blue Host. If you have a site created already use your FTP client and move the folder into the sites/all/themes folder.

You want to place your base theme here as this is the folder that Drupal will look for your sites themes. If you want, you can download other base themes and move them inside the sites/all/themes folder. That's it, well at least for the Drupal base theme.

I'll add a little sub-theme to my base theme, please

This is where things start to get exciting. By exciting, I mean that in the nerdiest of ways. With the base theme installed, go ahead and navigate to the folder labeled Zen. Within the Zen folder, you will see a folder labeled STARTERKIT. This folder is our sub-theme. One thing of note, Zen provides you a sub-theme some of base themes will not. This is just another reason Zen is a great option!

Which the STARTERKIT folder selected go ahead and cut and paste the folder within the themes folder. Yep, this is the same place you put the Zen base theme. So when you are done, you should have two folders under the themes folder, one for Zen, and one for STARTERKIT. It is super important that these both are on the same level. If they aren't on the same level, then Zen won't know how to reference the sub-theme you will create.

Getting into the sub-theme details

Things are progressing nicely. We now have our base theme and sub-themes installed and in the right locations. Now we are going to look at configuring the sub-theme.

The first thing I like to do is rename the STARTERKIT folder to something a little more meaningful. You can name the folder however you want, but a few things to keep in mind is to avoid spaces and use a name that represents the site your building. For example, I like to use the company name the site is for.

There are few files that will need some attention. The first file you want to look at is the STARTERKIT.info.txt file. An info file is a static file for defining and configuring a theme. Before we edit the contents of the file go ahead and rename the file. For consistency sake, I always name the info file the same name as my sub-theme. So if I named my sub-theme codekarate, my info file would be named codekarate.info. You can go ahead and get rid of the .txt extension also.

There is more in the .info file then I am going to cover in this post. If you would like more information about the .info file, just make sure to let me know in the comments below.

Within the .info file go ahead and change the name and the description to something that fits your sub-theme. For the description, it's could practice to include information as to what base theme this sub-theme is using. So for example you description might look like this: "A custom theme for [store], based off of Zen.". Take this for what it's worth, it's 100% preference. For now, that is all you need to change within the .info file.

Still within the sub-theme, open up the theme-settings.php and template.php files. Within both of these files, you want to change EVERY instance of STARTERKIT to your theme name. For my example, I would replace STARTERKIT with codekarate. It's important that this matches EXACTLY to your theme name. A little hack is if you use the find and replace feature you can pretty quickly replace all of those instances.

Customizing the look with templates

We've spent a lot of words to get to this point. Thankfully, you're so close to the finish line. Before you click off and start building, I want to show you one more thing.

Zen works off of templates. These templates use HTML and PHP to control how the content is displayed on the site. There are templates for a variety of different sections of your site. Each of these templates controls the HTML structure and what pieces of content get displayed. They are super powerful. Here's the but. Since you are building your own custom sub-theme you don't want to just rely on the templates provided by the Zen base theme. You want the control, now let's take that control.

Within the Zen folder, locate a folder called templates. Inside of this folder are all the templates that control the layout of your site. Go ahead and copy the html.tpl.php and page.tpl.php files and paste them within your sub-themes template folder.

To modify ANY template you HAVE TO HAVE the html.tpl.php file within your sub-themes template folder. If you don't, no changes will take effect. Also, by default if you don't copy a template from the base theme to your sub-theme Drupal will remain using the template in the base theme.

Don't mess with Zen

So you might be thinking why would I mess around with creating all this sub-theme stuff when Zen provides me everything I already need. The answer resides in Drupal being an open source technology. Since Zen was built and continues to be enhanced by a group of individuals, there will ultimately be improvements/updates that you will want. If you start to "hack" the Zen base theme, then you import those new updates all of your changes will be erased. Not good. Just save yourself the headache and late nights and avoid modifying any base theme.

Wrap it up already

Hopefully, now you have strong understanding of what it takes to set up a sub-theme. There are a few steps that need to be taken, but like anything if you do it a few times it becomes second nature. As Micheal Jordan famously said, "You miss 100% of the shots you don't take." Take the shot and create something beautiful.

Do you use a different base theme? Which one, why, what's different? Let me know in the comments below.

Happy Coding.

May 21 2015
May 21

Normally, I would do this video style, but I'm a wildcard people and today we write! Thanks to one of our Code Karate supporters, Pieter, I am going to walk you through how to use Drupal views, date and content types to automatically hide/show nodes based on date field. Let's get started.

Make sure that you have Drupal Views installed. If you're new to Drupal, Views is like oxygen to humans, you REALLY need it. Also, you can learn more about Views by watching this Drupal views video. Also, I installed the Drupal Date module. I will use this module to set the date for the node (explained more below). Besides Views and Date, you shouldn't need any other modules besides what already comes with Drupal core.

For my example, I am going to display a list of training times people could sign up for and then once the training session has passed the view will no longer show that training. Make sense? Let's build!

A quick note before we get ahead of ourselves. When you enable the Date module, make sure that you enable Date, Date API, Date Popup, and Date Views. These additional modules will make your life a little easier. You're welcome.

I think we're ready. To start, I am going to create a training content type. For the fields, I am just going to keep the defaults Title and Body and add additional field training date. Naturally, you can add other fields that fit your unique situation, but for the purpose of this example we won't need any other fields.

With that content type, I am going to create five different nodes. Each of these nodes will have a different date. For the sake of showing how to hide content based on date, I am going to make one of the nodes have a date in past. This node will be used to prove that my view is only showing training dates in the future.

With the nodes created, we now need to create a view. Before we start excluding dates from showing in the view, let's make sure we get a view that displays all the content we want. To do this, make sure you add all the fields you want for the training content type. For me, that means I have added the Title, Body, and Training Date fields. Also, under the Filter Criteria section I have limited it to only showing training content types. Doing this will show that I can display all the training content.

Next, we need to add a filter that will only show the training dates that are in the future and exclude those that have already happened. Remember, in my example I have added a date in past for my 1st training node. If the view is built correctly it shouldn't exclude the 1st training node, but still show the remaining four training nodes.

The first step to do this is to add a filter to your view. For the field, you will want to select the Training Date field (or whatever field you are using for the date). For the settings, keep everything default except for the granularity. I change this to be minute. The reason for this is because I want the training to be available to be seen right up until they start. If I kept the granularity at a day, it would be hidden at the beginning of the day.

The filter criteria are where we do the filtering for the view. In other words, this is what is telling the view to show or not show. Again, the goal is to hide old training once the date and time have passed. To do this, select the Is greater than operator and change the drop down to Enter a relative date. Within the relative date text field, enter "now". Why now? Now is a PHP date format that specifies the current date and time. So "now" is an always changing value, which is exactly what we want. There are tons of other PHP date strings that you can use if "now" isn't exactly what you are looking for. To learn more about those formats just go here.

That is it! Once you save your filter go ahead and take a look at the view. Again, if done correctly, we shouldn't see the 1st training node as that contains a date field less than "now".

Hopefully, you were able to follow along and get your view and content displaying correctly. Remember, you can use other PHP date formats to show/hide content based on your unique situation. There are an almost unlimited amount of possibilities.

This was a very simple way to filter content. Do you use a different way? If so, share it in the comments below.

Until next time, Happy Coding!

May 10 2015
May 10

Taking a content type and displaying it in a Drupal View is core to any Drupal website. If you are new to views, you can check out our Drupal views video. As you venture into views you will learn hundreds of ways to manipulate content to change the way the end user is able to interact with the content. To help enhance this, you can use the Views Isotope module. This module uses the jQuery isotope library to dynamically filter views content. As the title states, it’s pretty fancy.

To get an idea of what the library does visit the website for the library at http://isotope.metafizzy.co.

jQuery Views Isotope Module: https://www.drupal.org/project/views_isotope
jQuery Views Isotope Library: http://isotope.metafizzy.co/

May 01 2015
May 01

As a request from David over at luxor.me, we checked out the Mmenu module. This little gem allows you to use various javascript libraries to create a mobile friendly navigation. The navigation it produces is similar to the slide in menus you find side a lot of mobile applications.

Setting up this module isn’t the easiest thing in the world of installations. To get the module fully functioning you need to install the Drupal module plus 4 separate javascript libraries. The libraries and the links to those libraries are included below. Also, if you check out the module page you will see the creator added some basic documentation as well. This is worth checking out.

Word of caution, when you install the jquery.menu library make sure to use version 4.7.5 and NOT the latest 5.0 version. Not entirely sure why the new version doesn’t work, but trust me it doesn’t. Use 4.7.5 and you will avoid an unnecessary headache.

Mobile Sliding Menu: https://www.drupal.org/project/mmenu
Mmenu Installation Guide: https://www.drupal.org/node/2324017
Jquery.Mmenu (Use Version 4.7.5):https://github.com/BeSite/jQuery.mmenu/releases
hammer.js: https://github.com/hammerjs/hammer.js
jquery.hammer.js: https://github.com/hammerjs/jquery.hammer.js
Icomoon: https://www.drupal.org/files/mmenu-icomoon.tar_.gz
JQuery Update - https://www.drupal.org/project/jquery_update
Mmenu - http://mmenu.frebsite.nl/

May 01 2015
May 01

Sometimes you have a situations where your normal Drupal administration menu just won’t cut it. Maybe you have someone that needs to perform some administrative tasks on your site such as managing content and comments, or perhaps something more complex such as managing the Drupal blocks. This person might be a technical wizard, but there is also a good chance that they might not be. In fact, they might be the person in the office that calls you when their “computer is broke”.

If this is the case, then the Administration Menu Source module might be your saving grace. This module works with the Admin Menu module to allow you to specific different menus for the different user roles of your website. This makes it really easy to fine tune the usability of your site’s administration navigation to cater to specific types of users.

If you have multiple types of administrative roles that perform admin or managerial tasks on your Drupal site, go ahead and give this module a try. It’s easy to set up and will make things a little easier to find for everybody involved.

Note: Make sure to give the correct roles the "Access administration menu" permission so they can view the admin menu.

Apr 17 2015
Apr 17

In this episode we cover an overview of the Drupal 7 Views module. The Drupal Views module is probably the most popular Drupal module and is installed on almost every Drupal 7 website I build. It’s so popular in fact that it’s included in Drupal 8 by default.

The Views module allows you to easily build and format lists of content on your Drupal 7 site. If you need to build a simple list of Nodes, Views can do that. If you need to build a table listing, Views can do that too. In this video, we will go through an introduction and overview of Views, as well as a few example views. You will learn about the different types of content you can display with Views, different display settings, and other Views options.

This video is built to be an introduction for beginners and newcomers to Drupal to teach the basics of the Drupal 7 Views module. In this video you will create two views. The first will be a page view that displays a list of articles on your Drupal website. The second will be a block view that shows the titles of the last three articles on your Drupal website. Using the skills you learn in this video, you will be ready to tackle more complicated problems that can be solved with views.

Now go out and build yourself some views!

Apr 15 2015
Apr 15

Update: If you are looking for a written article, check out Master your Drupal Sub Theme.

In the final video of the 3 part series, we look at creating and configuring a Drupal sub-theme. Specifically, we will be created a sub-theme based off of the Zen theme. If you aren’t familiar with Zen, it is a very popular base theme used by thousands of designers as a starting point when building a custom website theme.

So what is a base theme? A base theme is simply a theme that's default stylings can be used IF the sub-theme doesn’t override it. In other words, a base theme provides the frame of the house and a custom sub-theme provides the finishes. You might be thinking why not just modify the Zen base theme. While you COULD do this, it is NOT recommended. The main reason you would avoid this idea is because when Zen gets updated by the community and you want to pull in those new changes (updates) you will override all of your custom work within those files. That is not good. If however you use a sub-theme updates will never occur, unless you yourself do them.

In the video, I walk you through getting both a zen base and sub-theme created. During this video, you will learn which files need to be modified to correctly tie in your sub-theme with Zen. Lastly, I will show you how you can add template files (the files that control the structure of the site) to your sub-theme. Knowing how to modify these files is crucial to being able to have complete control over the structure of your website.

Apr 13 2015
Apr 13

In part 2 of the 3 part series, we are looking at how get a Drupal website and database setup and running. If you followed part one, you will remember we are doing this all on our local environment using MAMP. As the video will show, we begin by going to Drupal.org/project/drupal and downloading the newest version of Drupal. At the time of this DDoD, Drupal is at version 7.36. It’s important to note however, Drupal 8 is available but at this time isn’t at a stable enough point in our opinions to work on.

After you get Drupal downloaded, you begin to work on setting up a database using MySQL. In the video, I show you the correct steps to creating and populating the database to reflect all the Drupal database tables that must be created. This part of the process can end up being somewhat tricky as you have to follow a particular set of steps. Each of these steps is explained in detail. Lucky for you.

Once the database is installed you begin to walk through an installation profile. After setting up the profile, you’re done! At that point, you will have a fully functional Drupal website. In that last video of the series, I will take you through how to build a Drupal sub-theme.

Apr 09 2015
Apr 09

If you are building out a Drupal 7 site you may some day run into a situation where you need to have more dynamic options for a field attached to a content type (or any other type of entity). If the default allowed values text area will not work for your situation, then you have come to the right place. In this tutorial, we will discuss two different ways to create a more dynamic options list for extending your allowed values.

Method 1: Entity Reference

The first and most common reason you will need a dynamic options list is to reference some other type of entity or content on your site. This is easily manageable through the Entity Reference module. You can use the Entity Reference module to create a field to reference to any other type of entity. I have many other posts/videos on the Entity Reference module so I won't spend much time on it, but it's a great module for any Drupal site builder to become familiar with. I use it on almost every complex Drupal site I work on.

Method 2: Change the allowed values function of your field

The method requires a little module development/PHP skills. This is useful if you need to pull in your options value from some other database table (maybe a custom built one or one created by a contrib module).

In order to easily follow along with this you will need to be using the Features module to export your field to a Feature module. I have many posts/videos on the Features module and an entire section of my 5 secrets ebook that covers how to use Features on your Drupal websites.

So the first step is to create your Feature module making sure to select the field that you want to create dynamic options for. Once that is finished you will have to make changes to some of the exported Feature module code.

What! Change the Feature module code?

You might be thinking "It doesn't seem like a good idea to change the code generated by the Features module". You would be 100% correct in this thinking. It's typically not a good idea to change the code of a Feature module. However, the Features module does a pretty good job maintaining custom changes you make (depending on where you make the changes).

For instance, I commonly use the .module file generated by the Features module to add simple helper functions or form alter functions that are directly related to the exported Feature module. This allows me to keep the related code with the related Feature. I have seen a lot of developers create a Feature module and a custom module for the related code. While this typically works OK the main problem with this is that now you have a custom module that depends on the Feature module, and the Feature module that might depend on the code of your custom module. This gives you a strange circular dependency situation. To avoid this, just add your code to the module file (just don't remove the includes line of code at the top). Trust me... it's safe to do this and sometimes it makes a lot of sense.

To change the allowed values of a field, you will need to find the file that was created and ends with .features.field_base.inc. So if your module is called my_feature_module you will need to open my_feature_module.features.field_base.inc.

Search the file for the field you created and whose options you want to control. It should look something like this:

// Exported field_base: 'field_my_feature_module_options'
$field_bases['field_my_feature_module_options'] = array(
  'active' => 1,
  'cardinality' => 1,
  'deleted' => 0,
  'entity_types' => array(),
  'field_name' => 'field_my_feature_module_options',
  'locked' => 0,
  'module' => 'list',
  'settings' => array(
    'allowed_values' => array(),
    'allowed_values_function' => '',
  'translatable' => 0,
  'type' => 'list_text',

You will notice there is an allowed_values_function element in the array. In this case, you will want to change that to a PHP function that you will need to create. So in this case we are going to create a function called _my_feature_module_options_list (this could be any function name you want). Also make sure your allowed_values element is set to an empty array.

'settings' => array(
  'allowed_values' => array(),
  'allowed_values_function' => '_my_feature_module_options_list',

You are now ready to create your function. Simply open up your .module file (in this case it would be the my_feature_module.module file) and add your function. If you want to create static values, your function will look like this:

function _my_feature_module_options_list() {
  return array(
    'option1' => t('Option 1'),
    'option2' => t('Option 2'),
    'option3' => t('Option 3'),
    'option4' => t('Option 4'),

If you wanted to pull values from a database table it might look something like this:

function _my_feature_module_options_list() {
  $results = db_query("SELECT value, label FROM {my_custom_table}");
  $options = array();
  foreach ($results AS $result) {
    $options[$result->value] = t($result->label);
  return $options;

In order to get this to work you will need to make sure your Feature module is enabled on your site and ensure it gets reverted back to the default state. Once you do this, your values should be dynamically created by your custom PHP function.

Summing up using the allowed values function

From my experience, I have never had an issue with the Features module overwriting my allowed_values_function setting. It's a pretty rare situation where you will need this as most use cases are covered by either a static allowed values list or can be handled by the Entity Reference module. If you do find yourself needing a dynamic list of options controlled by a PHP function, then the method presented above provides an easy solution.

So go ahead and make those allowed values dynamic and let me know what you think.

Apr 02 2015
Apr 02

It’s our 200th episode! For this video, I wanted to take a look at how to set up a local development system and then configure that to build a Drupal 7 site. In this video, I show you how to download MAMP, a local solution stack. For those not familiar with MAMP, MAMP stands for Mac OSX, Apache, MySQL, and Php. This full stack allows you to run a server on your local computer. In other words, using MAMP (or WAMP for windows) you will be able to run and build a Drupal site just like you would if you were hosting it on a third party's server (ie GoDaddy, Acquia, Pantheon, etc).

This is the first video in a three-part video series where you will learn how to install and configure MAMP. In the following two videos, I will show you how to download and configure Drupal and then show you how to set up the best file structure for getting started on the right foot.

As I mention in the video, I am using MAMP due to the Mac OS I am using. If you would like to see a video showing how to download and configure WAMP (Windows version of the local stack) just let me know in the comments.

Mar 29 2015
Mar 29

In the last episode, we learned about the Drupal Subuser module. In this episode, we continue where we left off but take a look under the hood at the module code of the Drupal Subuser module.

By following along with this episode you will learn some things such as:

  • How to open up a Drupal module file and what to expect
  • How to find and locate an issue within a Drupal module file
  • How modules modify forms with hook_form_alter()
  • How to debug PHP variables in a Drupal module
  • How to test our fix to ensure it works correctly

If you have never seen a Drupal module before this might be a little intimidating and I might go a little fast, but you will still learn a lot. You should be able to start seeing patterns within different Drupal modules on how modules are structured. Good luck and happy module investigating!

Mar 26 2015
Mar 26

Drupal 8 coming (queue suspenseful music)! One of the HUGE things with Drupal 8 is this term called "headless Drupal". Don't worry the Drupal drop isn't in any danger of losing precious head real estate, rather headless Drupal refers to using a different client-side (front-end) framework then the back end Drupal framework. From what I have read the goal is to have Drupal become the preferred back-end content management system.

Are curiosity has peaked and we have started looking into the various Javascript Frameworks that are available. As of now the one that is peaking our interest is Angular.js. If you are experimenting, what frameworks do you like? If you don't know where to start check out this infographic below. Special thanks to Anna Mininkova from Web Design Degree Center for sharing this with us.

Choosing a Javascript FrameworkSource: WebDesignDegreeCenter.org

Mar 19 2015
Mar 19

Hello everyone and welcome to another Daily Dose of Drupal. Today we’re on episode number 198. And today we’re going to be going over the Sub-User Module. The Sub-User Module allows you to create a user and then have that user be able to create users underneath themselves so you could have and what our example is going to be is a manager user that can create a content reviewers underneath them and then you can give them permissions to control, if they can edit or delete those sub-users and you can do all kinds of cool things.

So we’re going to be going over that today, but before we get started make sure to follow me on Twitter at smthomas3 if you haven’t already and check out codekarate.com. Make sure you’ll get some of the other videos and posts and you can learn a lot about Drupal and click this little link over here for the free sticker giveaway if you haven’t already and we will send you a Code Karate sticker right to your door. So let’s go ahead and get started.

We have our development site here that we will be working on and I’m going to go ahead and turn on the sub-user modules. The two we’re going to be going on today are just the sub-user and the sub-user UI. The Sub-User Switch Module allows you to switch to a sub-user or login as a sub-user. We won’t be going over that one. You can see I’m using the dev version, you shouldn’t have to use the dev version, but I was doing some testing. It does require the relation module so you’ll need to have that downloaded and installed in order for this to work.

So we’re going to go ahead and install this. And the next step, once these are installed, is to go to the permissions page and set permissions for the sub-user module. So I’m going to go ahead and sort this just for Sub-User permissions. And you can see we have a list of permissions here. The important one that you need to have is to allow them to create enough authenticated user. So in this case you can see I have a manager role and a reviewer role. Well what I would like to do is to allow the manager to create other accounts and possibly give those accounts a reviewer role so that I could either create just authenticated users or an actual authenticated user with reviewer role.

So in order to do that I need to make sure they have the manager account or manager role has create an authenticated permission check. I’m also going to give it create a reviewer permission. So let’s save that and what we will do is we will go ahead and create an account called Manager Quick and we will give it the manager role and in this case you’ll notice there’s a field, it’s user relations, so the store relationship that will allow for the management of the user. So I’ll go ahead and allow that. And just to check, you’ll notice that when you come to your account page, when I click over here there’s a sub-users option here. Under Sub-Users, I now have this manager option. So now this manager is technically a sub-user of Code Karate. And so if I edit this, you can see that it’s just like a normal edit page, there’s a sub-user limit.

We will go ahead and login as this manager. And you’ll notice if we go to your My Account page as the manager you’ll see sub-users here. It says the user currently doesn’t have any sub-users which make sense, but you can add a user. So if we click add you get the normal or what looks like the normal user add form. You’ll notice one difference, you don’t see any role selection and I’ll explain why in a second. That’s actually something that should be there, but it’s not showing up currently.

But let’s go ahead and create a reviewer. Okay so now a reviewer has been created. If I come back to my account page and go to sub-users I can see that reviewer one has been created. I don’t have any access to edit this user and currently the user only has the authenticated user role so obviously this isn’t right. So what we can do is let’s come back to our admin side and let’s go back to the permissions page. And let’s give the manager permission to edit sub-users and delete sub-users. So we will go ahead and save that and now if we come back our manager account and we refresh the page, you’ll see I now have Edit and Delete links.

So if I edit this user you will notice the role option does show up and it only shows those roles that I have permission to create for. So I can give them the reviewer role now. I can save that, and now when I come to the sub-users page you’re going to see they have the authenticated and reviewer role. So you might be wondering why you can’t select the actual role when you’re creating the account and there’s actually a bug out here on drupal.org which hopefully…by the time you’re watching this might already be fixed.

If it’s not you can see there’s a solution here and in the next video I’m actually going to show you not using necessarily this solution but how you could debug this and fix it on your own so we’ll get into a little module development and you’ll look at the details of the sub-user module and figure out how you could fix this to kind of work. And then of course you could have posted this issue yourself but we’ll go through that in the next video. But you’ll see what the sub-user module does is it allows you to really create a hierarchy of users of I guess relationships between users.

So, in this case, the manager is the sub-user of the Code Karate account but it also has sub-users of its own. So a manager could then manage multiple reviewers, manage their accounts on their site and they could be in charge of possibly reviewing content. They would only have the permissions that a reviewer would have. Make sure you’re careful of course when you’re giving out these permissions because these…whatever roles you allow to create accounts, they can possibly do things that could harm your site so you want to be very careful with the permissions. You, for example probably don’t want managers being able to create administrators.

So just keep that mind, it’s a really simple to use module, besides that one bug it seems to work really smooth and it allows you to go ahead and create all different kinds of user hierarchies on your site which can be really good especially if you have a lot of content and you want people to review it or you’re creating some kind of social networking site. I can see a lot of users for it.

So go ahead and give the sub-user module a try, make sure to check out codekarate.com, check the next video if you’re interested in learning a little bit of module development on how you could debug the problem that we found earlier on not being to actually select the role when you’re creating the account.
So we’ll do a little module investigation in the next episode. But that’s it for this time, make sure you get your free Code Karate sticker and I will see you next time. Goodbye!

Mar 13 2015
Mar 13

I recently received an email from someone who finished reading the 5 Secrets to Becoming a Drupal Ninja eBook. The question was how to set up Git for an already existing Drupal website. The question is a great one because almost everyone that uses Git now had this question at some point.

In this post, we will walk through a few options for how to go about setting up Git on an existing site with multiple Drupal environments (Development and Live). We will also assume that there might be changes on the Dev environment that have not been pushed up to Live yet. We will also assume initially that we will just use a single master Git branch.

If you want to learn more about Git, you can start with An introduction to Git (part 1).

Before you start: Figure out your workflow

Before you go ahead and try to get Git set up, you will want to take a little time to ensure you know how you want your workflow to work. These will vary depending on how your Drupal environments are set up, how many environments you have, and how many developers you might have working on the project. In this case, let's assume this is a relatively simple setup. Just a Development and Live environment with only a small number of developers.

In this case we will want Git installed on the server hosting the Live site as well as the server running the development environment (Note: This could be the developer's own computer). If we walk through the path of a simple new addition to the site, if might look like this:

  1. Changes are made on the development site
  2. Changes are added to Git (using the git add and git commit commands)
  3. Changes are pushed up to a third party Git hosting service (Github, Bitbucket, etc).
  4. On the live site the changes are pulled down (using the git pull command)
  5. If the new functionality changed the database, then the database update script is run (either through the drush updatedb command or through the Drupal /update.php page).
  6. If there are new modules that need to be turned on, they are turned on using the drush en command or by the Drupal Module Admin page.

Your workflow could have more steps than this, but this should give you the idea. By thinking about how code moves through the process initially, you will have a better grasp on how things need to be set up.

This is also a good time to go ahead and set up a new Git repository in your third party Git hosting service. When setting up your new Git repository using one of these services they will often give you the Git commands you will need to run for an existing project.

Git Setup on Existing Site

Note: Make sure you have adequate backups of your Live and Dev sites before getting started... just in case.

If you want Git set up now on all your environments and your Dev environment is not currently ready to go Live, then you will want to start on the Live environment. If you have command line access to the server, and this is a Linux server, you may be able to do this directly on the live server.

Inside the folder for your live Drupal site run the following commands (or the ones that your Git hosting service tells you to... they should be similar). Make sure to replace [git-remote-path] with the path to your hosted Git repository:

git init
git remote add origin [git-remote-path]
git add .
git commit -m "Initial Git commit for my Drupal site"
git push -u origin master

If you refresh the page on your Git hosting service, you should see the master branch with all of the code from your Drupal site. You are now ready to set up Git for your development environment.

In your development environment, I would start by renaming the project folder. If your project folder was currently called drupal7 and was in the /var/www directory on your server, then something like this would work:

mv /var/www/drupal7 /var/www/drupal7_backup

This renames the drupal7 directory to drupal7_backup. You are now ready to clone your Live Git repository:

cd /var/www
git clone [git-remote-path] drupal7

This will clone your live Git repository into a directory called drupal7. If you are following best practices on your development site, the only things that should have changed would all be located in the sites/all folder. If this is the case, then you can simply replace the current sites/all folder in your directory with the one from your drupal7_backup.

rm -r /var/www/drupal7/sites/all
cp -r /var/www/drupal7_backup/sites/all /var/www/drupal7/sites

Also keep in mind that your settings.php file (located in sites/default folder) might need to be copied from your drupal7_backup folder as well.

cp /var/www/drupal7_backup/sites/default/settings.php /var/www/drupal7/sites/default/settings.php

You are now ready to add and commit these changes to your Git repository.

cd /var/www/drupal7
git add .
git commit -m "Adding new features from development"
git push origin master

To pull these changes down to the live environment, just navigate to the project folder and run:

git pull

To pull down any code changes from development (then proceed through the other update steps mentioned above).

Git Wrap-up

That's it. There is really not much to it. From now on, anytime you make changes in your development environment you will follow your predetermined workflow. You will easily be able to view changes to your project code over time and sleep easier at night knowing you have the warm embrace of version control on your project.

Happy Drupal development! Let me know what you think in the comments below.

Mar 12 2015
Mar 12

Hey everybody and welcome to episode 197 of the Daily Dose of Drupal. I am Adam and today we’re going to be looking for something a little different. We’re not sure…you’re not going to be focusing on any specific module. Today we’re going to be looking at how to accomplish something in Drupal. And what we’re going to accomplish is we’re actually going to figure out how to display a view listing all of the nodes of a content type but excluding the node that we’re currently on in the view.

So that’s what we’re going to be accomplishing and I’m going to show and make more sense as we go along. But before we do that, of course, make sure you head on over to codekarate.com if you’re not already there and also make sure to check out our free sticker program we got going on. So in the corner you can click on that and we’re giving away free Code Karate stickers, trust me they’re completely free, no strings attached, we won’t charge you anything.

We ship this nice looking sticker to you if you just need to…all the thing we ask you in return is that you help us spread the word. So tweet it out to your friends and get other people to get some stickers that they can stick and spreading Code Karate word. Also while you’re at Code Karate make sure to check out all of the other things and again give us any thoughts on other modules or other things you want us to take a look at and we will do our best to get to those.

Alright, let’s get to the objective today. So what I want to do is again I want to display a block that list all of the nodes of a content type and then…but I don’t want to show the current node that I’m on. So to start, what I did is I created a content type called Blog and I added a bunch of…or just three different nodes for those blogs, so I got one, two and three in here. So if you see here I have blog test 1 and again let’s get it first to display all of the nodes of that content type. So to do that we can just simply create the easy view.

So we go to Structure, click o Views, add a new view, I’m going to call this…we’ll just call it blog post and then we want to up type content and we want to include it in just being blogs, we won’t include any of the rest of them We’re not going to create a page so we’re going to instead create a block and we’re just going to leave all the defaults fine and then you could see here below in our preview we’re seeing blog test 1, 2 and three getting displayed in all of our different blog types. So let’s go ahead and save that and I’ll just see how it looks like. So if we go back to structure blocks to get the block added, scroll down here to the view blog post, let’s add that to our first sidebar, save that and actually I’m also going to restrict that only to show on our blog content type.

So I’m going to come in here and select content types and click blog, and then if I close this you’ll see right here all my blog posts are showing up and I got one, two and three. We’ll that’s good and everything but for the goal of today it’s exactly to get blog test 1 not to show up because I’m already on that node. This doesn’t make much sense so if I go to two, two shows up which I already need a link back to the same page I’m already on so we need to get rid of that. So to do that all we need to do is edit our view and add a filter. So a filter with that is basically doing is it’s filtering the results before it gets displayed.

So to filter that I need to add a NID or the Node ID of the piece of content. So I’m going to go ahead and add that and in the Options menu here you want to do provide default value, under type we’re going to select content ID from the URL and remember in Drupal 7 content ID, Node ID same thing. So what’s that going to do is it’s going to grab the content ID or Node ID which if you look up in the bar here that’s the 10. So that’s our Node ID. So we’ll go ahead and grab that and we’re going to keep everything else default until we go to the bottom here under the more.

We want to inverse our rule so we’re going to click Exclude and what that’s basically doing is it’s flipping the rule. So if we read this here it says if selected, the numbers entered for the filter will be excluded rather than limiting the view. So what that means is it’s going tom say okay grab the 10 and if it’s the same as the Node ID we’re on which is the 10 then don’t show it. So we’re going to apply that filter and we’re going to go ahead and just save this and look and see if it works. So now you see what’s on blog test 2 or node ID 10, we don’t see blog test 2 over here because it’s the same. So excluding it, so if click on blog test 3, the three doesn’t show up on the list, blog test 1 that doesn’t show up on the list.

So again if we go back to the view just to show you, that’s how you exclude the node ID that you’re currently on. Again just adding a content filter, grabbing that ID from the URL or the node ID and then just making sure you come into the More settings and clicking the opposite or exclude checkbox. So that’s a really simple way to do this task, we don’t need to spend much more time on it but it’s definitely a handy thing, becomes in line, it’s definitely when you’re displaying blogs or similar type posts, nice way to limit that and make your user experience just that much better.

Alright so to end it today I want to leave you with a little quote, change things up a little bit. The quote is information without execution is poverty. It comes from a man named Tony Robbins and I think that’s very important in today’s world and even in with coding is, take the information that you learn from Code Karate or other resources and put that into practice. Not using information is worthless or poverty as Tony Robbins would say. So just get out there, just do whatever you think you need to do and make your dreams happen. Alright guys until next time, take it easy.

Mar 08 2015
Mar 08

Hello everyone and welcome to another Daily Dose of Drupal. Today we’re on episode number 196. Today we’re going to be doing something a little bit different than normal. We’re not just looking at a specific module but we’re going to look at how to build what I guess I’ve been calling kind of a dynamic display block with mini panels.

So you might want a little familiarity with panels if you’re going to follow along but you should be able to keep up even if you don’t have too much experience. So what we’re going to do, first I’m going to show you what I mean by dynamic display. So on the Code Karate site if you go to a Drupal Commerce related post if it’s tag with Drupal Commerce and you scroll down to the bottom you will see a block here that says we received our free collection of Drupal Commerce videos. If you go to a Git tag or I guess technically a version control tag post, you will see a completely different block here.

Just getting started with Git block and so what we really built is a way to base on the taxonomy term of the post, choose what kind of block or which block we want to display here and it’s just using panels so there’s probably ways you can do it especially if you wanted to spend a little time with some code you can do it more efficiently but it’s still a pretty easy way to create this without using any code at all. So make sure you’d have the panels module downloaded on your site and I’ll go ahead and get started with how to create this.

But before we do, make sure to check out codekarate.com. We have a whole bunch of things changing all the time on the site so you can check out the EBook, check out the Drupal Commerce course and just let us know if you see anything that you think we should do videos on the future. So I have our test site here and I’m going to go to the modules page and show that Panels and Mini-Panels are enabled so you can see mini-panels on and panels are also on. And if you go to our homepage there’s two articles here. This one is a test article and you can see it’s tagged with test and this one is called inspiring quotes and it’s tagged with the tag inspire.

So what we’re going to build is we’ll just build a mini-panel that will display something different depending on which post we click on depending on the tag. And we can go ahead and we’ll be able to put that block anywhere whether it’s on the sidebar, whether it’s below the post. You could actually put it within the post itself if you wanted to really did use panels. One thing to keep in mind when you’re doing this is you want to test this especially with caching because your page is completely cached. There are some things depending on tags so I just want to keep that in mind. Just test it beforehand but you should be okay to follow along with this.

So let’s go ahead to structure mini-panels and we’re going to create our first mini-panels. Let’s just call this Dynamic Display, we’ll leave everything else blank and hit Continue. We’ll then want to make sure we have a required context of node because we’re going to want them on a node page and you can leave the identifier and keyword, just set the defaults and hit Continue. For the layout it’s going to be a really simple layout so I’m just going to go to a single column.

You could make it as complex as you want but I’m going to keep it very simple. I’m just going to display one little piece of text depending on what type of article they’re on. So now we have our mini-panels or I guess similar to panels but editor where you can add content. So we’re going to first add a piece of content and I’m just going to use custom content here but you could use all different types of things. You could put other blocks in here, you could put comment form, you could do anything else that you could normally do with mini-panels or panels and add it into this actual mini-panel to display dynamically but I’m just going to go ahead and use custom content.

So I’ll do one, this one is going to be for…if the keyword or the tag is inspire so I’m just saying do you like inspirational post and I’ll click finish and then I’m going to add another one for that test tag and just say do you like post with the test tag. Just keep in mind that this is a really simple example but you can use it to put anything you want in here. So I’m going to go ahead and just finish this for now and let’s go ahead and look or add it to the sidebar and then we’ll look at how it looks just right now. So if we go down here and find mini-dynamic display, I’m going to put this in the sidebar first column just at the bottom and click Save.

I’m also going to come in here and configure it and only display it on article content types. You could of course determine how you want to do this and you might say, couldn’t we just use two different blocks and for this specific example you can’t because you can’t do it just based on taxonomy term if you want it to individually specify the pages, you could specify that, I only wanted to show the inspiring one on this page and the test one on the test page but that doesn’t work if you’re going to scale to hundreds or a couple of hundred posts on a site especially if you want it all controlled on taxonomy term.

The other thing to keep in mind with mini-panels is it doesn’t have to just taxonomy term. It could be controlled on specific field on a content type and I’ll go ahead and show you that a little bit but for now we’re just going to check just the article and now we’re going to go ahead and go back one of our articles and we should be able to see both of them, and it is not showing up. Okay so I think the reason that it’s not showing up is that in order for the mini-panel to actually get that node context that we pass in, we have to be using panels and page manager.

So what we’re going to do is we’re going to go ahead and turn that on for this article, and to do that we go to Structure Pages and you’ll see there’s a node view by default but by default it is disabled so we’re going to enable it. And then we need to make sure that our article page is actually using a variant in here. So we’re going to go ahead and add a new variant and we’re going to go ahead and do this just for articles so it’s not going to change any other content type. So to do that we add a variant and select Selection Rules, we’re to look for node type, click Add and find the article here.

This means this variant will only show up for article content type and everything else so all the other content types will go back to their normal display. So we’re going to go ahead and hit Continue and we’ll go ahead and keep this as flexible for now just in case we wanted to change it and we’re going to leave everything else on the panel settings page at its default and this is going to get us to a layout designer. So here is where we want to come in and add all of our fields, so we’d want to add our body, we’ll just add that quickly and I’ll also add the tags field so we can see that. I’m just going to leave everything as default so we can see it working. I’m just going to show that for now.

There’s more we can add but really what you want to do is you wanted to use panels to design out that article page and the it’s going to allow us to show the mini-panel in the block because the context of this panels page, this page manager panels page is going to then be pass into that mini-panel So that’s the only way that the mini-panel can be aware of the actual node that we’re going to need and we need that because without having the node available you’re not going to specify specific fields or specific taxonomy terms to use to decide which one to display. So that is important, so we’re going to click Create Variant and I’ll click Update and Save, you can see we are saved now so I’m going to go ahead and go back to the homepage. You’ll notice that the article page is going to look different, it doesn’t have the image, it’s not designed out quite the same.

We could change that of course but you will notice we have this little block here, this mini-panel and it has both. Do you like inspirational posts and do you like posts with a test tag? So what we’re going to do now is dependent on which article we’re viewing. We only want to see one of these. So how do we do that? Well we go back into mini-panels, so go back to structure mini-panels and we’re going to edit our mini-panel here. We’re going to go into content and we have our two different pieces of content. If we click the little Gear Icon over here there’s a visibility rule. And so what these Visibility Rules are and these are very dynamic and very flexible on what you can do but you can control what shows up based on specific conditions.

So we’re going to add a new rule here and we’re going to look for node tags I believe, node article tags field. So we’re going to select that, click Next and this is for the first one so we’re going to select the tag that we’re going to show and keep in mind this doesn’t have to be taxonomy. This could be a field you added. Maybe you’ll only ever going to have three blocks or three pieces of custom content and you want to add a dropdown with the three fields and based on what you select you want to show the specific one, you can do that.

The Visibility Rules, as you can see there’s a bunch of options you can actually put in php code if you don’t want it to be specific to one of the node fields. You could use similar blocks, you could use URLs, only show it for specific user, those types of things. But for this we’re just using the tags field so this one is only going to show with the test tag, is selected. So we’re going to click Save, now if I did this right and if we come back, if I click on the first article that’s tagged with test, you can see do you like posts with the test tag, if I come back to the other one you’ll notice it says do you like inspirational posts. So as you can see this is really dynamic and flexible for how you want to build out your site to show different dynamic blocks based on the taxonomy terms of the posts itself.

So you can get really crazy with it and put all of different kinds of things in these blocks so you could put the blocks anywhere but it’s very contextual in a way. It only shows what you want based on what is actually in the content itself. So it’s pretty cool and you can do all kinds of cool things similar to what we did with the Code Karate site and if you do use this, let me know, I’d like to take a look and we can definitely share it out and show off all the cool stuff you can do with mini-panels.

So that’s it for this time, I think we went a little long but I think it’s pretty useful and something that a lot of people would be able to use on a lot of different Drupal websites. Make sure to check out codekarate.com, sign up for the newsletter if you haven’t already and we’ll see you next time. Goodbye.

Feb 27 2015
Feb 27

You ask and you shall receive. That is exactly what happened. Roman, the supporter of the Range Module, asked us to review his module. So that is what we did.

The Range module allows you to add a CCK field that holds two values or a range. Like similar CCK fields there are a bunch of various configuration options available. Those include setting label text, minimums, maximums, etc. Also, the Range module provide three different types: integer, float and decimal. Depending on your need you can choose the best type for you. In the video, I cover the positives and negatives to using each type.

Thanks again to Roman for suggesting the Range module. It is a well built module that does the most important thing a module can do. It just works!

If you have any modules you want us to review make sure to use the contact link on the top of the CodeKarate.com site. Thanks.

Feb 27 2015
Feb 27

Hey everybody and welcome to episode number 195 of the Daily Dose of Drupal. I am Adam and today we’re going to be looking at a module suggested by the creator of the module Roman Pasca or on Drupal at Terren and that module he maintains is called range. So what this module does is it’s a pretty simple module that attaches to CCK and allows you to add a field for two different numbers or range.

So I’m going to showcase that in a second and give you a few examples of some used cases that would work with Range Module. But before we do that of course we need to head over to codekarate.com, make sure to check out everything what’s going on there. We just finish up our contest so that if you did enter the contest for our free Drupal Commerce course make sure to check your email. See if you want or get a discount code.

Also on Code Karate make sure to sign up to get the 5 Secrets EBook and also just check out anything you see on the site, love to hear feedback from you so let us know also like Roman did, make sure to tell us any modules you might want us to check out. So let’s get started, so the Range Module, so the Range Module is like I mentioned before, a module that’s going to allow you to do two different fields or two different numbers on the same CCK Field.

So you read through it here, there’s not a lot of set up, but it obviously does have a lot of functionalities actually built into the module. So what…the version is 7.13 here. Obviously it does have an alpha version for Drupal 8 so that’s pretty cool. If you’re looking to get ahead and do a Drupal 8 site you could use this module if needed. So make sure again if you are following the video that you’re using 1.3 otherwise there might be some differences that aren’t going to be covered in this video.

So let’s go ahead and get that module installed, so once we hop over to our site here and we’re going to hop over to our module’s page and make sure we turn the module on, scroll down a little way. You’ll see the module here is going fall under the fieldset called numeric range. There’s nothing co configure on it but make sure you just go ahead and turn it on and save the configuration. So once you have the configuration saved, that’s really all you need to do. Now when you go over to your content types, so under Structure Content Types you can now add this as an option or a field.

So I’m going to go and manage my fields on Houses content type that I created earlier. You see that I already have one in here and I wanted to get one in here so that I can walk you through it and then we can add another one as well. So one used case that I came up with is if you wanted to have potential users or realtors enter in specifics for houses that they might want or want to sell. So for example you could say for Bedrooms, I went in and say okay give me your lowest number of bedrooms and your highest number of bedrooms that you would allow me to have or you would want to sell. So you could enter that, you could also…and we’re going to add another field here for price or bathrooms or things of that nature. Another example would be is via a consulting company and especially in website development and you wanted to give your clients a range of fees.

So you want to say how much are you willing to spend, give us a range from zero to 10 or whatever they think is comfortable for them. So what we’ll do here is let’s add another range field. So we’re going to do Price, and then again on the dropdown here you’ll see three different ones that come along. There’s a decimal, a float range and then into the range. So you’re probably familiar with what a decimal range than a float or excuse me, an integer ranges but you’re probably not too familiar with what a Float Range is and to be honest with you, either was I but when I look it up, basically the main difference is float stores data a lot and takes up a lot less space than a decimal does.

I believe we found out about 20 times less which is pretty significant, but the caveat is it float and it stores it’s done is accurate. Basically, it can change a rounding issue. So for example if you’re using money as a range you don’t want to use Float because you want to be specific about the amount. If you’re using for example height or distance to the sun, you might be able to use a decimal value there it doesn’t have to be as accurate.

So for this example we’re doing Price so I’m just going to do decimal because I want it to be pretty accurate. I don’t care if it takes up a little more storage. And then here we go; so there’s some settings that we can specify the range for decimal and it says Precision. So it’s 200 digits and it’s stored in the database so we can store up to 10 digits, it’s the least end up to 32 is the most. So we’re going to keep it at 10, we’re going to store out full length, anything over that will get dropped and then the number of digits to the right of the decimal, we only want it to be two so keep it there and then we can say what’s our decimal marker and we want it to be a decimal point and not a comma.

And then again this thing will look very similar to any other CCK Field you’ve looked at, there’s a bunch of different configurations. It’s at minimum, it’s maximums, you can do a field prefix which is what I want to do so I’m going to give a dollar sign on that so four. And then again here’s some of the additional ones for your range so you have your from and your two. So you can say…I’m going to change this to say Minimum Price, I’m going to change the two to say Maximum Price. And again you can add prefix and suffixes as well. I will…all other suffix of just, I’m good. And then again if you want default values, again a lot of us will look pretty familiar.

Well let’s go ahead and save our settings and now let’s add in and if you go and add content to our houses we just scroll down here and you’ll see that now we have a minimum price of we can set there and I actually put the suffix right there so that doesn’t look really good so I probably want to get rid of that, but that’s where that would appear. So like I said, a minimum price of 50,000, maximum price of 120,000. And again I can go to decimal values If I wanted, but I won’t for this example. And for bedrooms Let’s say I want 0 to 3, we’re just going to give it title, we’re going to save this and then you’ll see here it adds a decimal value for me so it goes out to that 00. So again this is an as relevance since I’m that larger purchase or probably doesn’t need a decimal value but you’ll see how that works but just again displays it but we give can get rid of those semicolons since it doesn’t really make any sense there but you see how that works. So anyway that’s pretty much the Rang Module, again there’s three different options, there was the decimal which we showed you, the Float and then the Integer. So those are the options to input in and there’s a pile of a lot more examples on those, the ones that I came up with but needless to say it’s not the module you’re going to use every day or on every site, but it definitely is a module that will save you some time if this range issue means to come up. So again guys make sure that you go ahead and think [inaudible - 0:07:43.9] the module and all the other ones. He looks like he’s committed to so that’s awesome. Thanks again for recommending it Roman. Other than that make sure to check out codekarate.com. Again check out our EBook there and also our course and all anything else that might interest you as well. We love to hear feedback as well. So until next time guys, see you.

Feb 22 2015
Feb 22

Hey everybody and welcome to episode 194 of the Daily Dose of Drupal. Today we’re going to be looking at a module called Touch Icons. You might not be too familiar with what Touch Icons are but they basically are they allow when a user is using an iOS device and they bookmark a certain webpage, it’s the icon that would appear on their home screen.

So it’s a module that definitely kind of get overlooked but a module that really is helpful beings that iOS adoption is so high. So we’re going to take you kind of what that means and how that kind of looks once it’s done. So there’s a few ways to go about doing this. I’m going to show you all three ways that I know. I’m sure there’s others but these three will definitely work. So there is a Drupal module that will handle almost all of this for you and it’s the Touch Icons module.

So what this module basically does is it allows you to upload this Apple Touch icon to a distinct place and then it will reference that when a user wants to add as a bookmark on their mobile device. So that module is pretty easy to get installed so just download the zip file. Again I’m using 1.0 beta 2 and make sure if you are watching this on a later date you’re using the same version. It looks like it hasn’t been updated in a few years but it might change, you’ll never know. So just make sure to double check that.

So once you the module installed we can come over to our website here and get it enabled. So right there we’re going to enable it, we’ll make sure we save it and there’s no configuration you’ll see on that page specifically. When you do enable the Touch Icons module it will appear under your individual theme that you’re using. So modify that, we can go under Appearance and then use your theme user.

We’re using the default bartik. And then if you scroll to the bottom here you’ll see a field set for IOS Touch Icons and there’s two different versions in here. There’s the IOS Touch Icon and then IOS Touch Icon Pre-Compressed. Basically the difference is the pre-compressed version allows you more control over your ICON and it doesn’t’ allow IOS to do some special effects with your icon so that is if you look an IOS device you’ll typically see rounded corners and it has like a shadow effect to it. If you upload just to IOS Touch Icon it’ll do all of that for you. As the module reads here, it has a rounder corner and a glass effect overlay to the icon which is kind of nice. But some IOS devices don’t…basically don’t allow for this Touch Icon just by itself so it’s always best to upload both versions in your sight.

So once you get the module installed then you can easily upload an icon just to…this system. So we can click Upload Icon and you can find an icon. Here’s a little bit of a caveat, as IOS continues to grow and come up with new versions it obviously increases the size of the Touch Icon that’s needed. So from the little research I did, you best want and you’ve wanted upload as 152x152 image. If you have only here little quick, you’ll see here here’s the Apple Touch Icon that they’re using and this is obviously is specific to Apple and if we just look at the image real quick you’ll be able to see right there it says it’s 152x152 pixels. So that’s the icon I would recommend uploading. It’s also important to note how they save icon. You can see here that they save the icon as Apple-touch-icon.png.

So again, when somebody comes to apple.com it wants to bookmark that page. This icon right here you’ll see what will appear on their mobile device image. So on the home screen or in a folder or whatever, similar to any other app you would download. Okay so back to the sight here, so again I can just browse out to an icon. I’m just going to pick one that I downloaded here and when I upload this, again it’s called Apple-touch-icon.png and I’m going to do the same thing for my pre-compressed and again that’s the same exact name except for it’s got –pre-compressed on it and it’s a PNG as well. So once I do that I can save this and I see here now I have both of these uploaded to my system.

There’s the one and there’s the other one. So that’s all there is to the module really, so now when somebody would go and add an icon off f our website, this is what would appear and it would look. Again it went up here and it would look similar to this, so that will be a Drupal icon and again you can change this to modify that to whatever you’d want but again use that 152x152 size. So the other way I want to show you is that you actually probably don’t this module necessarily and there’s a lot of other ways to do it and it obviously makes it really easy to get that uploaded especially if you don’t have FTP access to your website so that would be the module I would use. But if you want to do it differently, you can actually pull up your FTP client and you’ll see here and you can actually upload these files directly to your directory.

So in Drupal the root directory is the directory in which your index.php file is in. So if we look here under the coat folder, we scroll inside of that, you’ll see right…there it is. Right there there’s our index.php so this is our root folder, so we easily can come over here to our icons that we have before and this is again this is on the left site here, here’s my home or local directory. I could go in here and I could drag this apple-touch-icon-png right into my root directory. And then in theory if I do that, I’m just looking here and then if I go to my development site here and I go appletouch-icon.png you’ll see it’s right there.

So that’s in my root directory so it’s right there, no folders or anything else needed and then that’s referencing this image or this image right here. So that would work as well as an option but the problem with that is if you have to update Drupal core or any major updates to your site, that will get erased so you’d have to redo it again which again one of the other good idea is you just have to drop it over again but let’s say you don’t want to use the module and you don’t want to put it in your root directory, it also allow you to specify this specific place for Apple to look for these images. So to do that, all you need to do is you need to come in to your index file so I’m just going to pull up one just for the…there’s maintenance-page.tpl.php files were the head of the document is located.

So that’s where we need to tell Apple to look for our Touch Icon. So I want to say I can just simply add a link here and I can do around and I just type in Apple Touch Icon so that’s what it is. And then I can do an Href and then this is exactly and then this is exactly I can tell where I want it to look. So instead of adding it to my root directory like I did before, I just went in here and I add it to my sights all themes images folder and you can see I have them both in there. I’m just going to grab this one. This is called Appletouch-icon.png.

So when I copy the URL to clipboard I’m going to come I here and paste that and you’ll get a lot of stuff I don’t need but if I can go all the way back down to the /sites folder so it’s now looking in sites all themes, images appletouchicon.png and then I can close that off right there and there we go. So now instead of having it to be in the root directory, it now can look for inside my theme which I don’t have to worry about updating and losing going forward. So that is it, listen guys, there’s three different ways to do it, one of them is again to…two different ways are to ignore using the module and simply upload to the…your individual theme right there or if you do want, you can upload it directly to the root directory. Again the root directory is located right inside your cold folder there, wherever the index.php file is located. Also if you do want to use the module, the module works really easily as well. Again all that works off of your appearance or your theme and then you can upload your icons right there for both pre-compressed and compressed or uncompressed Apple icon.

Again it’s really important to note that you want to use 152x152 size as in that will work for the different IOS versions especially the new stuff with iOS 6 and the iOS 6 plus versions. So there we go, so that’s all there is with the module, pretty simple, but again it’s a really nice little thing to add for users especially if you want them to bookmark it and have your branding be cohesive throughout your website. But one thing to note, if you do not have a Touch Icon, by default Apple will most likely just do a screenshot of your website. So it kind of ends up looking pretty white and plain typically.

So it’s always nice to have a logo attached to your brand. So anything else, any questions about it, make sure to leave them in a comments. Otherwise make sure to check out Code Karate, closing in to find out some contents we have going on as well as check out our courses we have as well and sign up for our newsletter. We love to hear from you and love to interact. So until next time, have a good one.

Feb 19 2015
Feb 19

The Drupal 7 Interval Field module provides a simple way to create a duration or interval field on any Drupal 7 field-able entity. A common use for this might be on a content type that generally keeps track of dates. Sometimes it easier to summarize a group of dates to a user or visitor using an interval field rather than selecting multiple dates.

An interval field is useful for keeping track of data such as:

  • 5 hours
  • 33 seconds
  • 7 days
  • 3 months

Installing and configuring the module could not get any easier. To see it in action, simply install it like you would any other Drupal 7 module, and make sure to enable it on your module administration page. Now when you go to add a field to a content type, user, comment, or any other field-able entity, you will be able to create an Interval field.

When configuring the interval field, you can reduce the options presented to the user when an interval is created. For example, you can limit the options to only show the users "days" and "months" rather than allowing them to select from all of the interval options.

Really a simple module that can be useful. It really works best to provide a simplified way to store an interval, but also a user friendly way to present the data to a website visitor.

Hello everyone and welcome to another Daily Dose of Drupal. I am Shane Thomas, you can follow me on Twitter at smthomas3, also make sure to check codekarate.com, learn a little bit about our Drupal Commerce Course and our 5 Secrets EBook. We are on Episode Number 193 today and it’s going to be a short one and we’re going to be looking at the Interval Field Module. If you ever had a situation where you need to allow a field to show basically a duration, so two months, three days, four years, something like that on your Drupal site.

The Interval Field Module is just the solution for you. So it’s not something that you can use too often but there are a few situations where it can be helpful. So we’re going to go ahead and make sure we have it installed on our test site here. As you can see I have the 7.x-1.0 version installed. And so we’re just going to go to a content type. I have content type called Training. I’m just going to add a duration field to this. I’ll call it Duration and it’s actually going to be an Interval Field. So select Interval, as soon as you turn on the module you’ll have a new field type.

There’s only one widget so we’ll leave that at its default. So we click Save and now it allows you to set a few options here. So the first one is the allowed periods, so what you select here will be selectable by the user when they’re entering the value for this field. So let’s say we want minutes, hours and days. Let’s put months too, so there we go. We’ll leave out the other ones and we’ll set the default value to two hours and click Save. We’ll move this up there and now we’re going to go ahead and create a training content. We’ll create some training.

Alright so we’re going to go ahead and call this one Week Long Conference and let’s say it’s 4 days. You notice there’s only the four options that we selected here. I could add some text if I wanted to in the body and I’m just going to leave that. So you can see I now have a duration field that says 4 days. Pretty simple, this is something sometimes you can use in replacement of a date field or an addition to a date field. If you have something that spans a long duration sometimes it’s hard for people to understand how long that really is.

So a Duration Field or an Interval Field can help with that. Let’s go ahead and add another one here; let’s say we are scheduling a month long class so we want to say 1 month. Notice that it says one month here but when you save it, it notice that this is the singular so it’ll take the S of it. So if we click Save, you’ll notice it says 1 month and not 1 months. So it’s a super simple, module, there’s not much to it but it’s something that I think can be useful in specific situations where you want to really keep track of that interval versus just having a set of dates.

So go ahead and check it out, let us know what you think and if you have any other suggestions for our future videos in the Daily Dose of Drupal, make sure to head over to codekarate.com, click on Contact or send me a message on Twitter or something like that. Just get a hold of me. Until next time, see you later.

Feb 12 2015
Feb 12

We kept things simple for this episode of the DDoD. The options element module uses Javascript to create an easy way to create radio button and checkbox options for fields on a Drupal content type. Before this module you had to add key|value for each options you wanted. Using this module the key and value is broken down into two fields making it easier to distinguish the difference.

Also, the added javascript will allow you easily add additional options with just a click of a "+" sign or delete an options with a click of the "x" button. Reordering is easier as well, you can simply drag and drop all the options to get the order exactly how you want it.

This is by knows means a life changing Drupal module, but I would recommend this module if you are looking to improve your user experience quickly and easily.

Feb 05 2015
Feb 05

In An Introduction to Git Part 4, you learned the basics of Git branches. You are now ready to push your Git repository to a Git hosting service such as Github or Bitbucket. After that, we will bring it all together and discuss possible ways to use Git in your next Drupal project.

Git is one of the secrets from my 5 secrets to becoming a Drupal 7 Ninja ebook, and much of the following posts are from this ebook. To learn more about Git and the other secrets, please consider purchasing the ebook or signing up for the 5 secrets email newsletter which will give you more information about the 5 secrets.

Pushing your Git Repository to Github or Bitbucket

In the next few sections we will look at both Github and Bitbucket and how to push your Git repository up to these Git hosting services. This section will only prove to be a really quick getting started. There is ample documentation on both of these services online if you choose to pursue using one or the other. First we will look at Github.

You will first need to create an account on github.com or bitbucket.com. Once you are logged into your account, you will want to set up your SSH keys. Your SSH Key is how Github or Bitbucket knows who you are. This way when you push up your changes, Github or Bitbucket will be able to determine if you have access to the Git repository you are trying to push or pull from. The first step is to make sure you have an SSH key setup on your local system. Since the setup varies depending on your operating system, you will want to search for something like “Generate SSH Key [operating-system]”. This should give you some results. If you are using a Linux based operating system or a Mac, you can probably just run the ssh-keygen command (however you should probably do a little research so you can understand the various options).

After you have an SSH key setup on your local system, you will have a .pub file available to you in your ~/.ssh/ directory (this might be slightly different on a Windows computer). Open up the .pub file (in my case it is id_rsa.pub) and copy the contents of the file.

In your Github or Bitbucket account, you will need to find the place in your account settings to manage your SSH Keys. You will need to add your SSH Key and probably give the key a title. You will then need to paste the contents from your .pub file into the Key section. You should now be hooked up to your Github or Bitbucket account allowing you to push and pull your Git repositories.

The next step is to create a new Git repository. When you create a new repository on Bitbucket or Github, you will be walked through the basic setup steps. You will then be given a few options and Git commands you can run. You should see some instructions showing how to push an existing repository from the command line.

Adding a Git remote

The first step to push up your existing Git repository is to add a new Git remote. You will then use this remote to push your Git repository to your Git hosting service.

Git Command What does it do? git remote add [remote-name] [remote-url] Adds a remote repository called [remote-name] located at [remote-url]. We can now push and pull from this repository (assuming we have permission). git push -u origin master Push our master Git branch to the remote called origin.

You should be able to copy and paste the git remote add command from Github or Bitbucket into your command line and run it. Then do the same with the git push -u origin master command. Your output should look something like this.

Git Add Remote

If you refresh the Github or Bitbucket page, you should now see your repository listed. You can now look through and begin using the online Git tools on your Git repository. Anytime you make a Git commit to your master branch you can simple run the git push origin master command to get the changes to be pushed up to Git hosting service. If someone else pushes changes to your Git repository and pushed it up, you can run a git pull origin master to pull in the changes to your local Git master branch.

You may have noticed that only the master branch is listed on Github or Bitbucket, you can push your other branches up as well. Simply run the git push origin [branch-name] command to push up a branch to your Github or Bitbucket repository or run git push origin --all to push up all your branches.

Using Git with Drupal

Now that you know the basics of Git, you are ready to apply this to your Drupal website. Go to your document root of your Drupal website and run the git init command.

Git Init Drupal

Drupal 7 comes with a .gitignore file for us to use. If you are using Git for a non Drupal project, you could create this with any text editor. The contents of the .gitignore file exclude the settings.php file, the Drupal files directory, and the Drupal private files directory. Here are the contents of the .gitignore file.

Drupal Git Ignore File

These patterns are set up to match files such as sites/default/settings.php as well as files such as sites/test.com/settings.php. This allows the Drupal multisite functionality to work correctly without allowing you to accidentally add in user generated files or a settings.php from one of your Drupal websites.

You are now ready to add all the files to your Git repository and make your first commit.

Git Add and Commit Drupal Repository

You are now able to use the Github, Bitbucket, or any other Git hosting service to push your repository up using the instructions above.

You may be thinking... "Is that it?" And the short answer is No, but it's a good start. There is not much difference using Git with Drupal or using Git on other types of files. The important thing is to remember that user generated files should not be added into the repository, and that you will most likely not want the settings.php file added into the repository (Note: some hosting services add in the settings.php file by loading in database credentials and other environment specific information from another file... but the important part is that your database credentials should not be in your repository).

Git summary: Where do you go from here?

Learning Git is intimidating. There are a lot of moving parts and a lot of things that can seem to go wrong. You will run into problems such as merge conflicts or trying to figure out how to undo commits, but these hurdles are worth the effort. Everyone makes mistakes, but what separates a Drupal developer from a Drupal Ninja, is the Drupal Ninja knows how to quickly and painlessly recover from those mistakes. You probably use some type of backup system for the hard drive of your computer. Git is like a supercharged collaborative backup and recovery system for your entire project.

If you liked learning about Git, make sure to check out the 5 Secrets to Becoming a Drupal 7 Ninja. It has some additional information on Git and other helpful secrets for building awesome Drupal websites. Also, grab a copy of the Code Karate Git Cheatsheet, to make remembering Git commands easy when you are just getting started.


About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web