Tips and Tricks

By adam
2015-06-14 08:48
2 comments
Daily Dose of Drupal Episode #208

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!

By adam
2015-03-26 07:33
3 comments

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.

By adam
2015-02-22 17:35
2 comments
Daily Dose of Drupal Episode #194

Today, there exist many different options to digest content. One of the most popular options is Apple products like the iPhone and iPad. A unique thing about iOS is that they use specific icons when users want to add your website as a bookmark on their home screens. This icon is then used to quickly launch your website, similar to how you launch a bookmark in your browser.

Normally, websites don't have this icon available so what almost always ends up happening is Apple using a screen shot of the webpage as the icon. Having a generic screen shot can effect your branding message.

By adam
2014-11-12 08:23
1 comment

There is a saying that "All good things come to those who wait". While whoever said that was most likely not referring to our Git cheat sheet, but the saying still holds true. As of right now, you get get your coding hands on the Code Karate Git Cheat Sheet by clicking here or going to the cheat sheets page (it is the same thing).

By adam
2014-10-21 10:42
0 comments

As developers we always are looking for ways to become more efficient. After all, time is money.

One of things we found that always cost us more time than needed was remembering Drush commands when building our Drupal websites. Obviously, Google will find thousands of sites with this information, but just having a sheet laying on our desks seems to provide the answer faster. Remember time is money.

Daily Dose of Drupal Episode #171

The Drupal 7 Search Krumo Module extends the Devel module and makes it easier to debug PHP variables while developing Drupal modules or building Drupal themes. It adds a simple search box that allows you to quickly search through the Krumo output that is generated by the dpm function.

If you want to try it out quickly, simply download and install the module and run the following code on the variable you want to debug:

The Problem

Style this using views and CSS. What you are looking at below is a view being displayed as a grid. This is by far the easiest way to display content in a nice looking grid view, but as you will read there is a MUCH better way.


By adam
2014-09-26 08:12
0 comments
Daily Dose of Drupal Episode #170

In this DDoD we look at the jReject module. This module allows you to display a modal popup notifying the user / visitor that their browser is outdated and wont work well with the site. In the video, you will see that jReject comes with a wide variety of customizations to fit your brand and preferences. Another important thing to note is that jReject unlike other similar modules allow you to display a popup based on other browsers besides the common Internet Explorer.

There are some times in Drupal 6 where you push the limits of what the blocks interface can do. If you need to display the same block, multiple times on the same page, you will start to see these limitations. An example of where this is useful is a Newsletter signup form. Sometimes a client may want a newsletter signup form to be in the footer of every page, but also displayed more prominently on the contact form page.

I recently was helping a new Drupal developer with some issues after they attempted a Drupal update that really messed up their Drupal website. They were getting a bunch of Fatal errors that were causing the site to be completely broken. This user was on a Windows system running a Drupal 7 development site on their localhost. Here are the steps I tried and how I fixed the problem.

Download a new Drupal 7 core

By shane
2012-12-12 12:14
3 comments

Have you ever ran into a problem where you needed to upload relatively large files and still want to be able to manage these from the Drupal 7 administrative interface? If so, you may run into a situation like the one below:

You will notice the 12 MB text stating that we can only upload files that are 12 MB and under. In this case I needed this number to be a little bigger.

By shane
2012-12-05 09:30
3 comments

I wrote a post on Hiding page titles for specific node types in Drupal 6, this is just an updated post for Drupal 7.

The code is essentially the same, but requires just a minor change. If you want to hide the page title on only the front page of your Drupal 7 website, add the following code to your themes template.php file (replacing THEMENAME with the name of your theme):

function THEMENAME_preprocess_page(&$vars) {
  if ($vars['is_front']) {
    $vars['title'] = '';
  }
}
By shane
2012-10-12 02:07
2 comments

Note: Turns out there is a much easier way to do this as there is an Ubercart function that does essentially the same thing (thanks to the comment below that pointed this out). Just use:

uc_product_is_product($node);

I left the original post below (although it is no longer really needed).

By shane
2012-07-30 16:39
4 comments

An easy one today. I often have to remind myself of how to convert a MySQL datetime to something a little more usable... a UNIX timestamp.

The strototime version

It is incredibly easy, just use the PHP strtotime function.

$timestamp = strtotime($result->my_datetime);

Now you can print the date in any format you want:

print date("Y-m-d H:i:s", $timestamp);

PHP5 Convert MySQL Datetime to PHP date format

If you are using PHP5, the following should accomplish the same thing.

 

By shane
2012-06-27 21:18
25 comments
As a follow up to my post on how to create a user account in Drupal 6 programmatically, I ran into a situation where I needed to do this in Drupal 7. Pretty similar but a few differences. So here you go:
 
  //This will generate a random password, you could set your own here
  $password = user_password(8);
 
  //set up the user fields
  $fields = array(
    'name' => 'user_name',
    'mail' => 'user_name@example.com',
    'pass' => $password,
    'status' => 1,
    'init' => 'email address',
By shane
2011-09-21 15:58
0 comments

The l function in Drupal is an easy way to output a link. If you need to add html within the link you can set an array with the correct options.

Here are a couple of examples using the l function.

By shane
2011-08-22 01:11
2 comments

If you are a Drupal developer than you often will run into the problem of having multiple user accounts on one site. This is especially important when you have many different roles/permissions to check. There are many useful tools for helping with this issue. One useful tool is the devel generate module which will allow you to create user accounts easily. There are also modules that allow you to "Spoof" these accounts by becoming that user.

By shane
2011-08-16 22:01
0 comments

Many people will instinctively enable the blog module when they are trying to build a blog using Drupal 6. It turns out that using the blog module is not necessarily the best option for building a simple, single user blog. Building a single user blog is easier to build using a simple content type that just flows into Drupal's default front page, or by using the views module to build a blog listings page.

By shane
2011-08-16 21:43
0 comments

I have seen many different methods to remove the "Search this site" text that sits in the Search block in Drupal 6. Because there are so many different approaches I wanted to show the way that I use in almost every site I build that contains a search block. The simplest way to remove the text is using CSS, however if you want to prevent it from showing up in the HTML markup completely just add this to a custom module (replacing MYMODULE with your module name):

By shane
2011-08-04 10:51
7 comments

If you have used the Quicktabs module, you know it is an easy way to displayed tabbed content on a Drupal site. However, I ran into the situation where I wanted to load a different default tab on a page. Quicktabs allows you to select the default tab to load, however in some circumstances it may be necessary to load a different tab by default (if a user is coming from another place on the site).

Subscribe to Tips and Tricks