I am new to drupal. I have created a block from module using hook_block_info() and hook_block_view(). This block will be used as front page image slideshow. So I want to provide text fields in the configuration page of that block where user can add Image files for slideshow.

What is the process of creating configuration form for the block. I searched online but couldn't understandable solution. Thanks!

I am using Drupal 7


You need to create a custom module for this. The module will create a database table that will store the image file path. The module will also provide an admin interface (drupal form) with a file field. When the admin uploads image and submits form, you need to store the file path in the database table you created. Now in hook_block_view() you need to iterate through every file path and render it as slideshow.

There is an alternate solution to your problem which will be more usable.

Create a content type with an image field. Now create nodes of that content type and upload images. Use views_slideshow module to display the nodes of the content type. Since it is a view, therefore you will be able to display it as a block and place it anywhere.

Hope the above solution will be more useful.


You can create block configuration page using hook_block_configure(). where you can create form with your required field like textfield, file etc.

function demo_block_configure($delta = '') {
    $form = array();
    if ($delta == 'demo') {
        $form['demo_number'] = array(
            '#type' => 'textfield',
            '#title' => t('Number of nodes you want the block to show'),
            '#default_value' => variable_get('demo_number', 10),
            '#size' => 60,
    return $form;

function demo_block_save($delta = '', $edit = array()) {
    if ($delta == 'demo') {
        variable_set('demo_number', $edit['demo_number']);

now you can get this variable using variable_get function

$no_of_block = variable_get('demo_number');

you can see this page in configuration of your block


You could take a look at the Examples module this provides code examples of various different api implementations, including block forms. The code your looking for is in the block module. All the examples are working so you can play around with them on a test Drupal 7 site if you want.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.