Skip to main content

Using the drupal_get_path() function to get the path of a theme

The drupal_get_path() function will look up a string (second argument) in Drupal's system table and find a path in the same row.

PHP Drupal Paths Themes Rows Strings Functions Database Lookup drupal_get_path()

How to manually login to Drupal

The login form can easily be found on a drupal installation by appending ?q=user to the end of the drupal installations root url.

Username Drupal Login Block Theme Installation Root URL Recover Logged Out

Getting the base url in Drupal 7

The global variable $base_url can be used to retrieve the base url within a drupal installation.

Drupal URLs Paths Variables Global

Getting the path to the current theme in Drupal 7

The current theme can be retrieved using the path_to_theme() function. It will return everything after the base url to the current theme.

PHP Base URL Drupal Paths Retrieve Return Themes Functions path_to_theme() print

Hooks in Drupal 7

Hooks, also called callbacks, can be described as internal Drupal events. Hooks essentially allow Drupal modules to hook into the rest of the Drupal installation.

Hooks Drupal

Shortcuts in Drupal 7

Shortcuts are one of the many new features found in Drupal 7. They allow admins, or members with permission to create their own sets of links that can be accessed by other users using a shortcut bar.

Drupal

How to call actions directly using actions_do() in Drupal 7

The trigger module is not the only way to call actions. Separate modules can be written to call actions and prepare parameters. This is typically done using a function called actions_do().

Drupal Actions Functions

How Actions are stored in Drupal 7

When an action is created, the information that is set in the configuration form is serialized and saved into the parameters field of the actions table. Immediately before the advanced action is executed, the contents of the parameters field are unserialized and included in the $context parameter.

Actions Databases Drupal Functions Advanced Action Serialized Saved Paremeters Actions Table Execute Contents Unserialized

Using the Context in Actions in Drupal 7

Actions can be called in different contexts. When an action supports multiple triggers, it determines which context it's being used in through the $context variable.

Actions Triggers Drupal

Creating and validating Forms for Advanced Actions in Drupal 7

The first function in the code below describes the form to drupal. The only form defined is a text field. The text field will be used so that the admin can designate the number of beeps.

Modules Hooks Actions Drupal

Creating Advanced Actions in Drupal 7

An advanced action can be based off of a normal action. The first thing to do is to tell Drupal that this action is configurable.

Actions Drupal

Using Advanced Actions in Drupal 7

There are two kinds of actions: ones that take parameters and those that do not. Advanced actions take parameters. When an action that requires setup in a configuration form is called an advanced action or a configurable action.

Actions Drupal

Retrieving the url of a node in Drupal 7

The node of a url can be retrieved using Drupals url() function.

Nodes Drupal

Creating an Action in Drupal 7

First thing to do when creating a new action is to inform Drupal which triggers the action should support. This is done by implementing hook_action_info() into our module file.

Drupal Actions Modules

Creating a simple new module that uses a hook in Drupal 7

The following snippet demonstrates how to create a module in Drupal 7. It will send a message to the log every time new content is created.

Drupal Hooks Modules

Using Triggers in Drupal 7

After enabling the trigger module you will see an option for Triggers under the Structure menu. On that page, the tabs across the top all correspond to Drupal hooks.

Drupal Triggers

Using Actions in Drupal 7

Actions are things that Drupal does such as deleting a user or promoting a node to the front page. Actions are functions that Drupal can couple with events.

Drupal Actions

Using hook_block_save() in Drupal 7

Save block-specific configuration settings. Configuration settings are defined in hook_block_configure().

Drupal Hooks

Using hook_block_view() in Drupal 7

Hook_block_view() takes in $delta as a parameter. $delta is the unique identifier for the block within the module. $delta is defined in hook_block_info(). It returns an array containing "subject" and "content".

Drupal Hooks

Using hook_settings() in Drupal 7

This hook declares admin settings for module. It provides admin interface for controlling settings for module. A menu item for module will appear in admin menu when the hook is implemented. It returns an array containing form items.

Drupal Hooks Modules

Using the t() function in Drupal 7

Translates a string to appropriate language. First argument should always be in english. It takes in $string, $args, and $options as parameters. $string is the english string to translate. $args is an associative array containing substitutions. $options is an associative array of additional options.

Drupal Functions

Using hook_menu() in Drupal 7

hook_menu() registers paths to define how url requests are handled. It returns an associative array. Its keys define paths. Its values are an associative array of properties for each path.

Drupal Hooks
Powered by Drupal 7. Made by Cody Bonney.