In drupal 7 we have something called contextual links. It is that little wheel you see when you hover over blocks so you can edit them in place. It is a great usability improvement but it is not always that clear how to implement them.
The contextual links functionality used to be a contrib module in d6 now it is a core module.
A handy new feature in drupal 7 are the local tasks. We will quickly explain two ways of adding them. Everybody should be
familiar with the two examples to be found in the node module. First example is the add content type on ''admin/structure/types".
First method to create a local task, we can use a hook_menu()
<?php /** * Implements hook_menu(). */ function node_menu() {
In drupal 7 the recommended method to render output is by using the render api. So no more calling theme(...) directly. Here is a simple example based on the example from the examples module.
<?php
function render_something() { $render_array = array( 'child' => array( t('This is some text that should be put together'), t('This is some more text that we need'), ),?>
When you query your entities on values on a field, for example you want to get all nodes via a node reference field. In our case we have an event and we want to know all referenced sessions to it.
If you want to render only one field of your entities you can in drupal 7. Here in the example we have an entity called model which contains an image field.
To render the field you have to specify to the field_attach_view function which entity type, the entity and the view mode you want to use. The function returns a renderable array.
If you want to save only a specific field on your entity instead of saving the whole entity you can. In a submodule of the fields module you ll find a module called field_sql_storage module. In that module all functions available for the sql storage backend can be used. One of them is field_sql_storage_field_storage_write, which you give your entity, type, operator (update, insert) and which fields to save.
This post will explain how to automate installing drupal on a development environment using a stack installer script.
We used the script to speed up a drupal training. With the script and the install profile we could set up a development workstation very fast. Leaving us more time to look at the important stuff.