note·book \ˈnōt-ˌbu̇k\
The place where I write things down.

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 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.


Subscribe to Notebook