drupal 7

Use AJAX in the Drupal Form API with Links (or any other element)

The use of #ajax attribute in the Drupal Form API is limited to a certain set of form elements. But what if you want to use a link to trigger your AJAX instead? It may be possible using the Drupal AJAX framework, but you'll need to figure out a way to pass the $form_state without breaking your form. There is a workaround that will allow you to use the AJAX built into the Form API with links or any other element.

Getting Started with Custom Node Access in Drupal 7

So you've come across a scenerio where you need to give users special access to nodes, but the collection of content access control modules available on drupal.org don't quite meet your need. Then you my friend need to build your own solution.

I found myself in the same boat, so I thought I'd share some of the articles that really helped me grasp custom node access.

Programmatically Set Node Type Visibility for Blocks

If you've ever created a block with hook_block_info you know that the visibility options are limited to just pages. In my case, I wanted to set my block to only appear on certain node types. The challenge is that you can't do it from hook_block_info because node type visibility isn't dictated by the block module, it's provided by the node module.

But fear not, there is a way! If you want to add content type based visibility for your block, you can do so in the .install file of your module using hook_install.

A Summary of Overriding template files in Drupal 7

Drupal's theme system allows you to provide alternate template files by way of theme hook suggestions. In other words, you can override the output of nodes, pages, blocks, and more by providing your own template file and using the correct naming scheme. For more information on that naming scheme I suggest reading this article on Drupal 7 Theme Hook Suggestions.

Preprocessing Fields from a Module in Drupal 7

If you're looking to preprocess a field in Drupal 7, you can use hook_preprocess_HOOK. The first "hook" is the name of your module. The second "HOOK" is the theme hook you want to preprocess (e.g. theme_node, theme_block, theme_link, theme_field). You can fine an exhustive list of the Drupal theme hooks by searching the Drupal API.

Here is a simple example of how to use it with fields.

Subscribe to RSS - drupal 7