Drupal

Using OOP styles for Drupal 7: callbacks

Drupal 7 was created mainly with a procedural style but OOP styles can be used in many parts of it.

For example, there're many callbacks used in the Drupal 7 system. Originally they're expected being functions but some callbacks can be replaced to methods. Here are some examples.

Batch callbacks.

We can use methods for batch callbacks. Because the callback is stored in the database with a serialized manner and invoked with call_user_func_array().

Drupal 7: How to disable a content type

While developing a site with Drupal, at times I'd like to disable a content type without removing it. I just want to disable one.

The database table where content types are stored is node_type. And there's a column disabled in it. We can disabled a content type by changing the column value to 1.

There are APIs for that. We can use node_type_load() and node_type_save() to do it.