Wednesday, June 28, 2017 05:01 pm EDT

Module Development

Bri's picture

How to Auto Node Title Nodes of a Certain Content Type in Drupal 7

Sometimes when you are creating a piece of content, the title field does not make sense to be filled out by the user. In these cases, its best to hide it and have it filled in automatically. Depending on your needs, the Auto Nodetitle may be able to give you everything you need.

After enabling the module, navigate back to basic editing of the content type you wish to configure, or add a new one. You will see a new option for "automatic title generation" with three options:

1. Disabled

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

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

Enhanced Recent Comments Module

The drupal core comes with a Recent Comments module, as you probably already know. This module doesn't allow for any configuration options, so I simply added to it. The core module is a block module that simply shows the 10 most recent comments. But what if you only want to show 5 posts, or perhaps only show comments from a particular content type? Below are the changes that i made. The majority of this code came directly from the drupal core comment.module file.

Syndicate content