planet drupal

Drupal - Hide the "Administrative overlay" Checkbox on the User Edit Form

Do you need to hide the 'Use the overlay for administrative pages' checkbox in the 'Administrative overlay' fieldset on the user edit form? Then look no further my child, this can be accomplished with hook_form_alter and an #after_build in your custom module.

Drupal - Commerce Price Range Navigation

While building a Drupal 7 Commerce site, I needed a price range navigation block so customers could search for products within a specific set of price ranges.

Here's an example website (buy some sexy clothes for your girlfriend/wife/self while you're there) showing off this feature.

Here's an example screen shot:

Drupal - Build a Mobile App to Geo Locate Node Content

In this tutorial we will explore how to build a mobile application for Android (iOS, iPhone, iPad) using PhoneGap and jQueryMobile that can be used to geo locate node content from a Drupal website. The mobile application will lookup the user's current location, then ask Drupal for a list of content closest to that user's location.

Tutorial Components

Drupal - Render an RSS Feed with PHP

Sometimes you want to show the output of an RSS feed somewhere in your Drupal site. Well with this handy dandy function, we can do just that:

Drupal - Render a View in a Node Template

In this example, we have a content type called Unit (machine name: unit). And we want to programatically render a view on its node template. So we'll do something like this:

1. Create a copy of our theme's default node.tpl.php file and save it as node--[type].tpl.php file in your sites/all/themes/my_theme directory. In this example, a file name of node--unit.tpl.php is correct.

2. Render the view into a theme variable.

Drupal - Add a Directory to Your Site's Include Path

Say for example, one of your Drupal modules needed to access some PHP function located in a PHP file in a directory somewhere on your server that wasn't in your Drupal directory.

/my_custom_directory/my_custom_php_library/my_custom_php_library.php

You can make Drupal aware of that directory by adding it to your site's include path. In your settings.php file for your Drupal site, add something like this:

Drupal - Change The HTML Output of Field

So I have been working on migrating a giant website from Drupal 6 to Drupal 7. As I migrate the content into Drupal 7 and review it, I often refer back to the Drupal 6 node to make sure the content was migrated properly. I was getting annoyed with copying the Drupal 6 node id rendered on the Drupal 7 node's page, opening a new browser tab, bringing up the old domain and then appending /node/# to it. Instead, I wanted to change the way the field is rendered in Drupal 7 by providing a simple link back to the Drupal 6 page.

Drupal - Save MySQL Data to Cache then Load it from Cache

Say for example you wanted to grab a list of all of your Drupal Content Types with a Node Count for each Content Type and display it as an html item list. That is easy enough with your own custom module and a bit of MySQL. However, on a site with thousands upon thousands (even millions) of nodes, this operation can be a little expensive on the server.

Drupal - Get List of Fields for a Content Type

To get a list of fields for a content type in Drupal 7, try the field_info_instances function.

Here is an example usage:

$my_fields = field_info_instances("node", "my_custom_content_type");

From here, I'll typically use the dpm function from the Devel module to see what is inside:

Drupal 7 - How to Modify a Views Query with a Custom Module

To make custom alterations, changes, adjustments, etc to a Views query in Drupal 7, try this module (or add the code in the .module and .view.inc files to your own custom module):

my_module.info

name = My Module
description = Behold my awesome module.
core = 7.x
package = Other

my_module.module

Pages

Subscribe to RSS - planet drupal