Thursday, August 17, 2017 09:41 am EDT

Drupal blog posts

Bri's picture

Theming the Contact Form in Drupal 7 (contact_site_form)

Theming the contact form in Drupal 7 is almost the same as most people did it in Drupal 6, but the one change through me for a loop for quite awhile.

Using Drupal 6, most people would add some code to their template.php file and create something like the following:

DRUPAL 6

function myTheme_theme() {
  return array(
	'contact_mail_page' => array(
					'arguments' => array('form' => NULL),
					'template' => 'contact-form',
					),
	);
}
function myTheme_preprocess_contact_mail_page(&$vars)
{
	$vars['name'] = drupal_render($vars['form']['name']);	
Bri's picture

An Example of Using db_query in Drupal 7

If you are writing your own modules, there is a good chance you have used db_query quite a bit in the past. The database layer has been overhauled in Drupal 7, and as a result, the way you get query results has changed slightly. Here is an example to how you how it's used.

// Notice the place holders are now done using the same syntax as PDOs (:uid)
// Placeholders also don't need to be quoted anymore.
$uid = 1;
$result = db_query('SELECT n.nid, n.title, n.created
FROM {node} n WHERE n.uid = :uid', array(':uid' => $uid));
Bri's picture

Template suggestions for Drupal 7 - theme_hook_suggestions

I decided to take some time to figure out how template suggestions work in Drupal 7 being that the release date is getting very close. At the time of this writing Drupal 7 is in RC 4, but they are saying that it will be released officially on January 5th of 2011. I have been working with 7 for a few weeks and finally decided to see if I could get the template suggestions to work. A few things have changed, but they are not that much different from the way they worked in 6. The first difference is that 7 uses a double "-" for its templates by default.

Bri's picture

How to Patch a Drupal Module on Windows

If you use Drupal on a regular basis, chances are that you will want to apply a patch to a module at some point in time. Perhaps somebody has posted a patch in the issue queue that sounds like it will address a problem you are having. Patching files on windows is simple. Just follow these steps.

1. You will need to download the patch software. You can download the Patch program at http://gnuwin32.sourceforge.net/packages/patch.htm

2. Run the setup file and install the program using all of the default settings.

Bri's picture

Using a Custom Image Button with Drupal 6 Search Form or Block

So you decided that you want to use an image instead of styling the inputs for the Drupal search block or form. Luckily, this isn't a difficult task at all. Using the hook_form_alter you can accomplish this. You will need to create a small module in order to make this happen. I called mine "modified_search". Here is what the .info file looks like:


; $Id:
name = Modified Search
description = Inject the search how i want it to look.
package = Other
version = VERSION
core = 6.x

And now for the contents of the .module file:

Bri's picture

Create Custom Drupal 6 Search Box and Theme It

If you are looking for a way to customize the search box in Drupal 6, here are some suggestions that may prove helpful. This info pertains to the search that is built into some themes rather than the search block.

The core search module specifies that the template to be used for the search_theme_form should be search-theme-form.tpl.php. If you theme doesn't already have this file included, you can copy it from the core search module folder.

Bri's picture

Theming Drupal 6 Login Form or Login Block

Often times people want to theme the drupal login page or the login block for the theme they are using. If you need to go beyond just changing the CSS and want to actually add markup to the login form, this will show you how.

First you are going to need to locate the template.php file in your theme folder. We need to add some code to that file. Open up the template.php file for your theme and add the following:

Bri's picture

Configuring Drupal 6 With Google AdSense Module

I had some trouble when I initially tried setting up AdSense ads on my drupal 6 site. Here are some instructions to help you get it working if you are experiencing trouble.

If you haven't already, download the AdSense module form http://drupal.org/project/adsense

Bri's picture

PHP Email Address Validation

Email address validation is a very common thing and it's pretty easy in php 5.2 or greater. You no longer need to use a regular expression. You can use this simple script below, making use of the filter_var function.


$email = 'mail@example.com';
$validation = filter_var($email, FILTER_VALIDATE_EMAIL);

if($validation)
$output = 'proper email address';
else
$output = 'wrong email address';

echo $output;

Bri's picture

Creating Drupal Template Suggestions

Chances are that you have wanted to create a new template as you work on your Drupal sites. Perhaps the blog page needs to have some markup that varies from your typical page.tpl.php template. Adding some lines of code to the template.php file inside the theme you are using can help you achieve this. By default Drupal will look for templates that match the name of a content type. For example, if you created a template called node-blog.tpl.php, Drupal would recognize it and load it on pages that contained blog content.